mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 19:11:25 +01:00
fix: address verified review findings (pulls-1)
Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
15 files changed
+202
-8
No files matched your search
@@ -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}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user