fix: address verified review findings (pulls-1)

Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
bircni committed 2026-10-18 17:39:24 +02:00
1 parent 58f0fc4bf9
commit 401650b489
15 files changed
+202 -8

No files matched your search

+6
View File
@@ -159,6 +159,9 @@ var (
unknownUser = regexp.MustCompile(`user does not exist \[uid: \d+, name: ([^\]]+)\]`)
// pullTargets finds the branches in "pull request already exists for these targets [... head_branch: x, base_branch: y]".
pullTargets = regexp.MustCompile(`head_branch: ([^,\]]+), base_branch: ([^,\]]+)`)
// missingBranch finds the branch in the 404 messages `ref "x" does not exist` (create pull
// request) and `new base 'x' not exist` (edit pull request).
missingBranch = regexp.MustCompile(`^(?:ref "([^"]+)" does not exist|new base '([^']+)' not exist)$`)
// wikiTitle finds the page in "wiki page already exists [title: Home.md]".
wikiTitle = regexp.MustCompile(`\[title: (.+?)(?:\.md)?\]`)
)
@@ -186,6 +189,9 @@ func Classify(err error, kind, key, scope string) error {
}
return conflict
}
if match := missingBranch.FindStringSubmatch(apiErr.Message); apiErr.Status == http.StatusNotFound && match != nil {
return &NotFoundError{Kind: "branch", Key: strconv.Quote(cmp.Or(match[1], match[2])), Scope: scope, Err: err}
}
if apiErr.Status == http.StatusNotFound && kind != "" {
return &NotFoundError{Kind: kind, Key: key, Scope: scope, Err: err}
}