Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions internal/reconcilers/pipeline_git_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ func cloneOrPullRepo(targetPath string, pipelineRelease string) (string, error)
return "", err
}

// Reset the worktree to discard any local changes
// This avoids reconciliation errors when anything other than `main` is used in the CR
if err := w.Reset(&git.ResetOptions{Mode: git.HardReset}); err != nil {
return "", err
}

// Checking out the hash value of the branch/tag that was requested
if err := w.Checkout(&git.CheckoutOptions{Hash: ref.Hash()}); err != nil {
return "", err
Expand Down