Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use ignore_paths while checking large projects during rill start #5164

Merged
merged 2 commits into from
Jul 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 31 additions & 4 deletions cli/cmd/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package start

import (
"fmt"
"io/fs"
"os"
"path/filepath"
"strings"
Expand All @@ -11,7 +12,9 @@ import (
"github.com/rilldata/rill/cli/pkg/gitutil"
"github.com/rilldata/rill/cli/pkg/local"
"github.com/rilldata/rill/runtime/compilers/rillv1beta"
"github.com/rilldata/rill/runtime/drivers"
"github.com/spf13/cobra"
"gopkg.in/yaml.v3"
)

// maxProjectFiles is the maximum number of files that can be in a project directory.
Expand Down Expand Up @@ -204,17 +207,41 @@ func StartCmd(ch *cmdutil.Helper) *cobra.Command {
return startCmd
}

func countFilesInDirectory(path string) (int, error) {
// a smaller subset of relevant parts of rill.yaml
type rillYAML struct {
IgnorePaths []string `yaml:"ignore_paths"`
}

func countFilesInDirectory(projectPath string) (int, error) {
var fileCount int

if path == "" {
path = "."
if projectPath == "" {
projectPath = "."
}

var ignorePaths []string
// Read rill.yaml and get `ignore_paths`
rawYaml, err := os.ReadFile(filepath.Join(projectPath, "/rill.yaml"))
if err == nil {
yml := &rillYAML{}
err = yaml.Unmarshal(rawYaml, yml)
if err == nil {
ignorePaths = yml.IgnorePaths
}
}

err := filepath.Walk(path, func(path string, info os.FileInfo, err error) error {
err = filepath.WalkDir(projectPath, func(path string, info fs.DirEntry, err error) error {
if err != nil {
return err
}
path = strings.TrimPrefix(path, projectPath)

if drivers.IsIgnored(path, ignorePaths) {
if info.IsDir() {
return filepath.SkipDir
}
return nil
}
if !info.IsDir() {
fileCount++
}
Expand Down
Loading