Skip to content

Commit

Permalink
fix: fetch before checking status (runatlantis#3832)
Browse files Browse the repository at this point in the history
* fix: fetch before checking status

* Switch to fetch
  • Loading branch information
lukemassa authored and ijames-gc committed Feb 13, 2024
1 parent 5787e0d commit ea4cf3e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions server/events/working_dir.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,15 @@ func (w *FileWorkspace) HasDiverged(cloneDir string) bool {
// we assume false here for 'branch' strategy.
return false
}

statusFetchCmd := exec.Command("git", "fetch")
statusFetchCmd.Dir = cloneDir
outputStatusFetch, err := statusFetchCmd.CombinedOutput()
if err != nil {
w.Logger.Warn("fetching repo has failed: %s", string(outputStatusFetch))
return false
}

// Check if remote main branch has diverged.
statusUnoCmd := exec.Command("git", "status", "--untracked-files=no")
statusUnoCmd.Dir = cloneDir
Expand Down

0 comments on commit ea4cf3e

Please sign in to comment.