From a555c24a9fb68eee8127f1e9eadf6bccd8c0c347 Mon Sep 17 00:00:00 2001 From: Virgil Date: Thu, 2 Apr 2026 01:35:55 +0000 Subject: [PATCH] feat(issues): add tracked time deletion Co-Authored-By: Virgil --- issues.go | 6 ++++++ issues_test.go | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/issues.go b/issues.go index 14a5f1e..e19858d 100644 --- a/issues.go +++ b/issues.go @@ -218,6 +218,12 @@ func (s *IssueService) ResetTime(ctx context.Context, owner, repo string, index return s.client.Delete(ctx, path) } +// DeleteTime removes a specific tracked time entry from an issue. +func (s *IssueService) DeleteTime(ctx context.Context, owner, repo string, index, timeID int64) error { + path := ResolvePath("/api/v1/repos/{owner}/{repo}/issues/{index}/times/{id}", pathParams("owner", owner, "repo", repo, "index", int64String(index), "id", int64String(timeID))) + 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 8113e21..c94fedf 100644 --- a/issues_test.go +++ b/issues_test.go @@ -1196,6 +1196,26 @@ func TestIssueService_ResetTime_Good(t *testing.T) { } } +func TestIssueService_DeleteTime_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/times/99" { + 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.Issues.DeleteTime(context.Background(), "core", "go-forge", 42, 99); 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)