From 68d5594373ef39de083b8e8af1e94f6d12eab12c Mon Sep 17 00:00:00 2001 From: Clovis Delarue Date: Mon, 11 Sep 2023 13:45:59 +0200 Subject: [PATCH] feature: Add summary support in AddSpentTimeOptions This commit is adding a `summary` field in the `AddSpentTimeOptions` structure. This structure is used to call the add spent API endpoints for merge requests and issues. Today we can only pass the duration of the time spent when calling gitlab API, however the 2 endpoints also accept a `summary` optional field. Adding this new field in the structure will allow users to set a specific `summary` value while calling gitlab API. [1]: https://docs.gitlab.com/ee/api/merge_requests.html#add-spent-time-for-a-merge-request [2]: https://docs.gitlab.com/ee/api/issues.html#add-spent-time-for-an-issue --- issues_test.go | 2 ++ time_stats.go | 1 + 2 files changed, 3 insertions(+) diff --git a/issues_test.go b/issues_test.go index 102575652..16f52c6a5 100644 --- a/issues_test.go +++ b/issues_test.go @@ -775,10 +775,12 @@ func TestAddSpentTime(t *testing.T) { mux.HandleFunc("/api/v4/projects/1/issues/5/add_spent_time", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodPost) testURL(t, r, "/api/v4/projects/1/issues/5/add_spent_time") + testBody(t, r, `{"duration":"1h","summary":"test"}`) fmt.Fprint(w, `{"human_time_estimate": null, "human_total_time_spent": "1h", "time_estimate": 0, "total_time_spent": 3600}`) }) addSpentTimeOpt := &AddSpentTimeOptions{ Duration: String("1h"), + Summary: String("test"), } timeState, _, err := client.Issues.AddSpentTime("1", 5, addSpentTimeOpt) diff --git a/time_stats.go b/time_stats.go index c1256b965..0ce2d6751 100644 --- a/time_stats.go +++ b/time_stats.go @@ -104,6 +104,7 @@ func (s *timeStatsService) resetTimeEstimate(pid interface{}, entity string, iss // GitLab docs: https://docs.gitlab.com/ee/workflow/time_tracking.html type AddSpentTimeOptions struct { Duration *string `url:"duration,omitempty" json:"duration,omitempty"` + Summary *string `url:"summary,omitempty" json:"summary,omitempty"` } // addSpentTime adds spent time for a single project issue.