Skip to content

Commit

Permalink
fix failing check for branch not existing
Browse files Browse the repository at this point in the history
Signed-off-by: natasha41575 <[email protected]>
  • Loading branch information
natasha41575 committed Oct 11, 2023
1 parent a9d5a36 commit 9bb0668
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions porch/pkg/git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,13 +466,9 @@ func (r *gitRepository) removeDeletionProposedBranchIfExists(ctx context.Context
deletionProposedBranch := createDeletionProposedName(path, revision)
refSpecsForDeletionProposed.AddRefToDelete(plumbing.NewHashReference(deletionProposedBranch.RefInLocal(), plumbing.ZeroHash))
if err := r.pushAndCleanup(ctx, refSpecsForDeletionProposed); err != nil {
if strings.HasPrefix(err.Error(),
fmt.Sprintf("remote ref %s%s required to be", branchPrefixInRemoteRepo, deletionProposedBranch)) &&
strings.HasSuffix(err.Error(), "but is absent") {

if errors.Is(err, git.NoErrAlreadyUpToDate) {
// the deletionProposed branch might not have existed, so we ignore this error
klog.Warningf("branch %s does not exist", deletionProposedBranch)

} else {
klog.Errorf("unexpected error while removing deletionProposed branch: %v", err)
return err
Expand Down

0 comments on commit 9bb0668

Please sign in to comment.