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 <natashasarkar@google.com>
  • Loading branch information
natasha41575 committed Oct 11, 2023
1 parent a9d5a36 commit c087ffa
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions porch/pkg/git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,13 +466,10 @@ 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") {

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

// the deletionProposed branch might not have existed, so we ignore this error
return nil
} else {
klog.Errorf("unexpected error while removing deletionProposed branch: %v", err)
return err
Expand Down

0 comments on commit c087ffa

Please sign in to comment.