mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 15:13:57 +00:00
fix(pulls): report stack merge API permission errors
Assisted-by: Codet:GPT-5-Codex
This commit is contained in:
1 parent
ba167a7352
commit
f28a5e696a
2 files changed
+21
-1
No files matched your search
@@ -120,7 +120,7 @@ func AddPullStackEntry(ctx stdctx.Context, login *config.Login, owner, repo stri
|
||||
return &s, nil
|
||||
}
|
||||
|
||||
// RestackPullStack queues a restack of every entry above the merged pull request in the stack.
|
||||
// RestackPullStack queues a restack starting at the stack's base branch.
|
||||
func RestackPullStack(ctx stdctx.Context, login *config.Login, owner, repo string, id int64) error {
|
||||
client := api.NewClient(login)
|
||||
resp, err := client.DoContext(ctx, http.MethodPost, fmt.Sprintf("/repos/%s/%s/stacks/%d/restack", owner, repo, id), nil, nil)
|
||||
@@ -156,12 +156,18 @@ func MergePullStack(ctx stdctx.Context, login *config.Login, owner, repo string,
|
||||
if resp.StatusCode == http.StatusAccepted {
|
||||
return nil, true, nil
|
||||
}
|
||||
if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusConflict {
|
||||
return nil, false, stackAPIError(resp)
|
||||
}
|
||||
|
||||
var body stack.MergeResult
|
||||
if decodeErr := json.NewDecoder(resp.Body).Decode(&body); decodeErr != nil {
|
||||
return nil, false, fmt.Errorf("%s: failed to decode response: %w", resp.Status, decodeErr)
|
||||
}
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
if body.Error == "" {
|
||||
return &body, false, fmt.Errorf("%s", resp.Status)
|
||||
}
|
||||
return &body, false, fmt.Errorf("%s", body.Error)
|
||||
}
|
||||
return &body, false, nil
|
||||
|
||||
Reference in new issue
Block a user