Skip to content

Commit

Permalink
print status when git is in a dirt state - fixes #10
Browse files Browse the repository at this point in the history
  • Loading branch information
edaniszewski committed Apr 1, 2021
1 parent f66613e commit 6b28ddf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions pkg/utils/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package utils
import "strings"

// IsDirty checks whether a repository is in a dirty state (has uncommitted changes).
func IsDirty() bool {
func IsDirty() (bool, string) {
out, err := RunCommand("git", "status", "--porcelain")
if strings.TrimSpace(out) != "" || err != nil {
return true
return true, out
}
return false
return false, ""
}

// GetTag gets the latest git tag for a repository.
Expand Down
3 changes: 2 additions & 1 deletion pkg/v1/stages/setup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,12 @@ func (Stage) Run(ctx *ctx.Context) error {
}

log.Debug("checking if git is in a clean state")
if utils.IsDirty() {
if isDirty, out := utils.IsDirty(); isDirty {
if ctx.AllowDirty {
log.Info("allowing git to be in a dirty state")
} else {
if err := ctx.CheckDryRun(ErrDirtyGit); err != nil {
log.Errorf("dirty git state detected\n" + out)
return err
}
}
Expand Down

0 comments on commit 6b28ddf

Please sign in to comment.