feat(pulls): add scheduled auto-merge cancellation
All checks were successful
Security Scan / security (push) Successful in 11s
Test / test (push) Successful in 1m3s

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Virgil 2026-04-01 23:03:31 +00:00
parent 93708fd0ec
commit 85d4ae6cc8
2 changed files with 26 additions and 0 deletions

View file

@ -32,6 +32,12 @@ func (s *PullService) Merge(ctx context.Context, owner, repo string, index int64
return s.client.Post(ctx, path, body, nil)
}
// CancelScheduledAutoMerge cancels the scheduled auto merge for a pull request.
func (s *PullService) CancelScheduledAutoMerge(ctx context.Context, owner, repo string, index int64) error {
path := ResolvePath("/api/v1/repos/{owner}/{repo}/pulls/{index}/merge", pathParams("owner", owner, "repo", repo, "index", int64String(index)))
return s.client.Delete(ctx, path)
}
// Update updates a pull request branch with the base branch.
func (s *PullService) Update(ctx context.Context, owner, repo string, index int64) error {
path := ResolvePath("/api/v1/repos/{owner}/{repo}/pulls/{index}/update", pathParams("owner", owner, "repo", repo, "index", int64String(index)))

View file

@ -273,3 +273,23 @@ func TestPullService_Merge_Bad(t *testing.T) {
t.Fatalf("expected conflict, got %v", err)
}
}
func TestPullService_CancelScheduledAutoMerge_Good(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodDelete {
t.Errorf("expected DELETE, got %s", r.Method)
}
if r.URL.Path != "/api/v1/repos/core/go-forge/pulls/7/merge" {
t.Errorf("wrong path: %s", r.URL.Path)
http.NotFound(w, r)
return
}
w.WriteHeader(http.StatusNoContent)
}))
defer srv.Close()
f := NewForge(srv.URL, "tok")
if err := f.Pulls.CancelScheduledAutoMerge(context.Background(), "core", "go-forge", 7); err != nil {
t.Fatal(err)
}
}