diff --git a/cli/internal/fs/package_deps_hash.go b/cli/internal/fs/package_deps_hash.go index edcd1d9f66afc..866d4847b3fad 100644 --- a/cli/internal/fs/package_deps_hash.go +++ b/cli/internal/fs/package_deps_hash.go @@ -66,7 +66,7 @@ func GetPackageDeps(repoRoot AbsolutePath, p *PackageDepsOptions) (map[string]st } // Update the checked in hashes with the current repo status - gitStatusOutput, err := gitStatus(p.PackagePath, p.GitPath) + gitStatusOutput, err := gitStatus(repoRoot.Join(p.PackagePath), p.GitPath, p.InputPatterns) if err != nil { return nil, err } @@ -303,15 +303,21 @@ func parseGitFilename(filename string) string { } // gitStatus executes "git status" in a folder -func gitStatus(path string, gitPath string) (string, error) { +func gitStatus(path AbsolutePath, gitPath string, inputPatterns []string) (string, error) { // log.Printf("[TRACE] gitStatus start") // defer log.Printf("[TRACE] gitStatus end") p := "git" if len(gitPath) > 0 { p = gitPath } - cmd := exec.Command(p, "status", "-s", "-u", ".") - cmd.Dir = path + cmd := exec.Command(p) + cmd.Args = append(cmd.Args, []string{"status", "-s", "-u"}...) + if len(inputPatterns) == 0 { + cmd.Args = append(cmd.Args, ".") + } else { + cmd.Args = append(cmd.Args, inputPatterns...) + } + cmd.Dir = path.ToString() out, err := cmd.CombinedOutput() if err != nil { return "", fmt.Errorf("failed to read git status: %w", err) diff --git a/cli/scripts/e2e/e2e.ts b/cli/scripts/e2e/e2e.ts index f98320c2f3a32..c90004f816711 100644 --- a/cli/scripts/e2e/e2e.ts +++ b/cli/scripts/e2e/e2e.ts @@ -300,6 +300,11 @@ function runSmokeTests( ); // run a task without dependencies + + // ensure that uncommitted irrelevant changes are also ignored + repo.modifyFiles({ + [path.join("packages", "a", "README.md")]: "important text", + }); const lintOutput = getCommandOutputAsArray( repo.turbo( "run", diff --git a/cli/scripts/monorepo.ts b/cli/scripts/monorepo.ts index bf7405489c24f..98348596a854a 100644 --- a/cli/scripts/monorepo.ts +++ b/cli/scripts/monorepo.ts @@ -246,7 +246,7 @@ fs.copyFileSync( return execa.sync("git", ["checkout", "-B", branch], { cwd: this.root }); } - commitFiles(files, options: { executable: boolean } = { executable: false }) { + modifyFiles(files: { [filename: string]: string }) { for (const [file, contents] of Object.entries(files)) { let out = ""; if (typeof contents !== "string") { @@ -265,16 +265,11 @@ fs.copyFileSync( } fs.writeFileSync(fullPath, out); - - if (options.executable) { - fs.chmodSync( - this.subdir != null - ? path.join(this.root, this.subdir, file) - : path.join(this.root, file), - fs.constants.S_IXUSR | fs.constants.S_IRUSR | fs.constants.S_IROTH - ); - } } + } + + commitFiles(files) { + this.modifyFiles(files); execa.sync( "git", [