mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-05 21:38:13 +02:00
fix(pulls): report stack merge API permission errors
Assisted-by: Codet:GPT-5-Codex
This commit is contained in:
@@ -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