feat(pulls): add scheduled auto-merge cancellation
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
93708fd0ec
commit
85d4ae6cc8
2 changed files with 26 additions and 0 deletions
6
pulls.go
6
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)))
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue