Skip to content

Commit

Permalink
cmd/gorelease: migrated git status --porcelain to git diff
Browse files Browse the repository at this point in the history
The expectation of this application is that it is to be utilized in release
pipelines. Due to this expectation, pipelines utilize volume mounting to
transfer artifacts (untracked files) across different jobs (specifically
referring to GITLAB here).

This is a problem because git status --porcelain checks for untracked files
and returns them as a list. This causes this pipeline to fail unexpectedly.

In testing, `git reset --hard` will not remove these, while a
`git clean -fdx` will correctly remove these files.

I would recommend that in a follow-up commit there is an update to the
available args for this cmd to control if untracked files are to be
included or not (eg: --untracked)
  • Loading branch information
UnaffiliatedCode committed Mar 20, 2024
1 parent 1b97071 commit d0f001e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/gorelease/gorelease.go
Original file line number Diff line number Diff line change
Expand Up @@ -1507,7 +1507,7 @@ func shortRetractionRationale(rationales []string) (string, bool) {
// changes.
func hasGitUncommittedChanges(dir string) (bool, error) {
stdout := &bytes.Buffer{}
cmd := exec.Command("git", "status", "--porcelain")
cmd := exec.Command("git", "diff")
cmd.Dir = dir
cmd.Stdout = stdout
if err := cmd.Run(); err != nil {
Expand Down

0 comments on commit d0f001e

Please sign in to comment.