From 060de1796c079e4c616090d026f54ee0e0c71e56 Mon Sep 17 00:00:00 2001 From: Virgil Date: Wed, 1 Apr 2026 06:25:32 +0000 Subject: [PATCH] Add issue stopwatch delete API Co-Authored-By: Virgil --- docs/api-contract.md | 1 + issues.go | 6 ++++++ issues_test.go | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/docs/api-contract.md b/docs/api-contract.md index 9670fef..45f2332 100644 --- a/docs/api-contract.md +++ b/docs/api-contract.md @@ -109,6 +109,7 @@ Coverage notes: rows list direct tests when a symbol is named in test names or r | method | IssueService.AddLabels | `func (s *IssueService) AddLabels(ctx context.Context, owner, repo string, index int64, labelIDs []int64) error` | AddLabels adds labels to an issue. | No direct tests. | | method | IssueService.AddReaction | `func (s *IssueService) AddReaction(ctx context.Context, owner, repo string, index int64, reaction string) error` | AddReaction adds a reaction to an issue. | No direct tests. | | method | IssueService.CreateComment | `func (s *IssueService) CreateComment(ctx context.Context, owner, repo string, index int64, body string) (*types.Comment, error)` | CreateComment creates a comment on an issue. | `TestIssueService_Good_CreateComment` | +| method | IssueService.DeleteStopwatch | `func (s *IssueService) DeleteStopwatch(ctx context.Context, owner, repo string, index int64) error` | DeleteStopwatch deletes an issue's existing stopwatch. | `TestIssueService_DeleteStopwatch_Good` | | method | IssueService.DeleteReaction | `func (s *IssueService) DeleteReaction(ctx context.Context, owner, repo string, index int64, reaction string) error` | DeleteReaction removes a reaction from an issue. | No direct tests. | | method | IssueService.IterComments | `func (s *IssueService) IterComments(ctx context.Context, owner, repo string, index int64) iter.Seq2[types.Comment, error]` | IterComments returns an iterator over all comments on an issue. | No direct tests. | | method | IssueService.ListComments | `func (s *IssueService) ListComments(ctx context.Context, owner, repo string, index int64) ([]types.Comment, error)` | ListComments returns all comments on an issue. | No direct tests. | diff --git a/issues.go b/issues.go index 15306a4..c9d81de 100644 --- a/issues.go +++ b/issues.go @@ -70,6 +70,12 @@ func (s *IssueService) StopStopwatch(ctx context.Context, owner, repo string, in return s.client.Post(ctx, path, nil, nil) } +// DeleteStopwatch deletes an issue's existing stopwatch. +func (s *IssueService) DeleteStopwatch(ctx context.Context, owner, repo string, index int64) error { + path := ResolvePath("/api/v1/repos/{owner}/{repo}/issues/{index}/stopwatch/delete", pathParams("owner", owner, "repo", repo, "index", int64String(index))) + return s.client.Delete(ctx, path) +} + // AddLabels adds labels to an issue. func (s *IssueService) AddLabels(ctx context.Context, owner, repo string, index int64, labelIDs []int64) error { path := ResolvePath("/api/v1/repos/{owner}/{repo}/issues/{index}/labels", pathParams("owner", owner, "repo", repo, "index", int64String(index))) diff --git a/issues_test.go b/issues_test.go index a00fff0..7178160 100644 --- a/issues_test.go +++ b/issues_test.go @@ -187,6 +187,24 @@ func TestIssueService_Pin_Good(t *testing.T) { } } +func TestIssueService_DeleteStopwatch_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/issues/42/stopwatch/delete" { + t.Errorf("wrong path: %s", r.URL.Path) + } + w.WriteHeader(http.StatusNoContent) + })) + defer srv.Close() + + f := NewForge(srv.URL, "tok") + if err := f.Issues.DeleteStopwatch(context.Background(), "core", "go-forge", 42); err != nil { + t.Fatal(err) + } +} + func TestIssueService_List_Bad(t *testing.T) { srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusInternalServerError)