From 85d4ae6cc89005d448112efe4a658d7aa557acf2 Mon Sep 17 00:00:00 2001 From: Virgil Date: Wed, 1 Apr 2026 23:03:31 +0000 Subject: [PATCH] feat(pulls): add scheduled auto-merge cancellation Co-Authored-By: Virgil --- pulls.go | 6 ++++++ pulls_test.go | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/pulls.go b/pulls.go index b5fac00..9d69a96 100644 --- a/pulls.go +++ b/pulls.go @@ -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))) diff --git a/pulls_test.go b/pulls_test.go index eadd3d8..762eae4 100644 --- a/pulls_test.go +++ b/pulls_test.go @@ -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) + } +}