CI: add log for branch deletion (#60647)

* add log for branch deletion
* return an err when branch deletion fails
This commit is contained in:
Kevin Minehart 2022-12-21 13:27:49 -06:00 committed by GitHub
parent a16ca209fb
commit dc00f6dbe3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -1,6 +1,8 @@
package main
import (
"fmt"
"log"
"os"
"strconv"
@ -113,9 +115,11 @@ func completeEnterpriseCheck(c *cli.Context, success bool) error {
}
// Delete branch if needed
log.Printf("Checking branch '%s' against '%s'", git.PRCheckRegexp().String(), opts.Branch)
if git.PRCheckRegexp().MatchString(opts.Branch) {
log.Println("Deleting branch", opts.Branch)
if err := git.DeleteEnterpriseBranch(ctx, client.Git, opts.Branch); err != nil {
return nil
return fmt.Errorf("error deleting enterprise branch: %w", err)
}
}

View File

@ -105,8 +105,7 @@ func AddLabelToPR(ctx context.Context, client LabelsService, prID int, newLabel
func DeleteEnterpriseBranch(ctx context.Context, client GitService, branchName string) error {
ref := "heads/" + branchName
_, err := client.DeleteRef(ctx, RepoOwner, EnterpriseRepo, ref)
if err != nil {
if _, err := client.DeleteRef(ctx, RepoOwner, EnterpriseRepo, ref); err != nil {
return err
}