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 5ec1782
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 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") {

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)

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

0 comments on commit 5ec1782

Please sign in to comment.