Skip to content

Commit

Permalink
bugzilla: improve identifierNotForPull error
Browse files Browse the repository at this point in the history
The `release-controller` is encountering an error for an invalid pull
identifier for a github link that is not a pull. This PR imporves
identification for non-pull github links to prevent that.
  • Loading branch information
AlexNPavel committed Jan 13, 2022
1 parent 571d659 commit 2885ffd
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions prow/bugzilla/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -968,12 +968,12 @@ func IdentifierForPull(org, repo string, num int) string {

func PullFromIdentifier(identifier string) (org, repo string, num int, err error) {
parts := strings.Split(identifier, "/")
if len(parts) >= 3 && parts[2] != "pull" {
return "", "", 0, &identifierNotForPull{identifier: identifier}
}
if len(parts) != 4 && !(len(parts) == 5 && (parts[4] == "" || parts[4] == "files")) && !(len(parts) == 6 && (parts[4] == "files" && parts[5] == "")) {
return "", "", 0, fmt.Errorf("invalid pull identifier with %d parts: %q", len(parts), identifier)
}
if parts[2] != "pull" {
return "", "", 0, &identifierNotForPull{identifier: identifier}
}
number, err := strconv.Atoi(parts[3])
if err != nil {
return "", "", 0, fmt.Errorf("invalid pull identifier: could not parse %s as number: %w", parts[3], err)
Expand Down

0 comments on commit 2885ffd

Please sign in to comment.