Skip to content

Commit

Permalink
🚸 Stop producing errors from stderr
Browse files Browse the repository at this point in the history
(cherry picked from commit 2853b7c)
  • Loading branch information
hybloid authored and avafanasiev committed Sep 4, 2024
1 parent c10bc8b commit 981c1d8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions platform/git_changes.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ type ChangedFiles struct {
Files []*ChangedFile `json:"files"`
}

func computeAbsCwd(cwd string) (string, error) {
func computeAbsPath(cwd string) (string, error) {
cwd, err := filepath.EvalSymlinks(cwd)
if err != nil {
return "", err
Expand All @@ -58,20 +58,24 @@ func computeAbsCwd(cwd string) (string, error) {
}

func GitChangedFiles(cwd string, diffStart string, diffEnd string, logdir string) (ChangedFiles, error) {
absCwd, err := computeAbsCwd(cwd)
absCwd, err := computeAbsPath(cwd)
if err != nil {
return ChangedFiles{}, err
}
repoRoot, err := GitRoot(cwd, logdir)
if err != nil {
return ChangedFiles{}, err
}
absRepoRoot, err := computeAbsPath(repoRoot)
if err != nil {
return ChangedFiles{}, err
}

stdout, _, err := gitRun(cwd, []string{"diff", diffStart, diffEnd, "--unified=0", "--no-renames"}, logdir)
if err != nil {
return ChangedFiles{}, err
}
return parseDiff(stdout, repoRoot, absCwd)
return parseDiff(stdout, absRepoRoot, absCwd)
}

// parseDiff parses the git diff output and extracts changes
Expand Down
2 changes: 1 addition & 1 deletion platform/git_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func TestGitFunctionalityChange(t *testing.T) {
t.Fatalf("New and expected repo urls are not equal: new: %v expected: %v", remoteUrl, REPO)
}
rootPath, _ := GitRoot(projectPath, temp)
if rootPath != projectPath {
if filepath.ToSlash(rootPath) != filepath.ToSlash(projectPath) {
t.Fatalf("Computed git root path are not equal: new: %v expected: %v", rootPath, projectPath)
}
}
Expand Down

0 comments on commit 981c1d8

Please sign in to comment.