Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Commit

Permalink
feature: Add summary support in AddSpentTimeOptions
Browse files Browse the repository at this point in the history
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
  • Loading branch information
airclovis committed Oct 5, 2023
1 parent e104217 commit 68d5594
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions issues_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions time_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 68d5594

Please sign in to comment.