这是indexloc提供的服务,不要输入任何密码
Skip to content

Apply inputs filter to uncommitted changes #1223

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

Merged
merged 4 commits into from
May 11, 2022
Merged
Show file tree
Hide file tree
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
14 changes: 10 additions & 4 deletions cli/internal/fs/package_deps_hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions cli/scripts/e2e/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,11 @@ function runSmokeTests<T>(
);

// 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",
Expand Down
15 changes: 5 additions & 10 deletions cli/scripts/monorepo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand All @@ -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",
[
Expand Down