Skip to content

Commit

Permalink
Only git stash in ci if dirty
Browse files Browse the repository at this point in the history
  • Loading branch information
davegaeddert committed Sep 10, 2019
1 parent a8f3f48 commit bb6bdf5
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions internal/runner/ci.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,20 @@ func CI(autoconfigure bool, types []string) error {
output.Event("%d existing updates", len(existingUpdates))

// TODO this is also because collectors may have done some crap and not cleaned up
output.Event("Temporarily saving your uncommitted changes in a git stash")
stashed := git.Stash(fmt.Sprintf("Deps save before update"))

// Stash pop needs to happen last (so be added first)
defer func() {
if stashed {
output.Event("Putting original uncommitted changes back")
if err := git.StashPop(); err != nil {
output.Error("Error putting stash back: %v", err)
if git.IsDirty() {
output.Event("Temporarily saving your uncommitted changes in a git stash")
stashed := git.Stash(fmt.Sprintf("Deps save before update"))

// Stash pop needs to happen last (so be added first)
defer func() {
if stashed {
output.Event("Putting original uncommitted changes back")
if err := git.StashPop(); err != nil {
output.Error("Error putting stash back: %v", err)
}
}
}
}()
}()
}

output.Event("Performing %d new updates on %s", len(newUpdates), startingBranch)

Expand Down

0 comments on commit bb6bdf5

Please sign in to comment.