Loading issues.go +14 −2 Changes for issues.go: 14 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -416,6 +416,7 @@ type CreateIssueOptions struct { // AssigneeIDs is a EE-only attribute. For CE, use AssigneeID instead. AssigneeIDs *[]int64 `url:"assignee_ids,omitempty" json:"assignee_ids,omitempty"` MilestoneID *int64 `url:"milestone_id,omitempty" json:"milestone_id,omitempty"` Milestone *string `url:"milestone,omitempty" json:"milestone,omitempty"` Labels *LabelOptions `url:"labels,comma,omitempty" json:"labels,omitempty"` CreatedAt *time.Time `url:"created_at,omitempty" json:"created_at,omitempty"` DueDate *ISOTime `url:"due_date,omitempty" json:"due_date,omitempty"` Loading @@ -424,6 +425,8 @@ type CreateIssueOptions struct { DiscussionToResolve *string `url:"discussion_to_resolve,omitempty" json:"discussion_to_resolve,omitempty"` Weight *int64 `url:"weight,omitempty" json:"weight,omitempty"` IssueType *string `url:"issue_type,omitempty" json:"issue_type,omitempty"` Severity *string `url:"severity,omitempty" json:"severity,omitempty"` StartDate *ISOTime `url:"start_date,omitempty" json:"start_date,omitempty"` } // CreateIssue creates a new project issue. Loading @@ -440,8 +443,9 @@ func (s *IssuesService) CreateIssue(pid any, opt *CreateIssueOptions, options .. // UpdateIssueOptions represents the available UpdateIssue() options. // // To reset the due date, epic, milestone, or weight of the issue, set the // ResetDueDate, ResetEpic, ResetMilestone, or ResetWeight field to true. // To reset the due date, epic, milestone, start date, or weight of the issue, // set the ResetDueDate, ResetEpicID, ResetMilestoneID, ResetStartDate, or // ResetWeight field to true. // // GitLab API docs: https://docs.gitlab.com/api/issues/#edit-an-issue type UpdateIssueOptions struct { Loading @@ -453,6 +457,7 @@ type UpdateIssueOptions struct { // AssigneeIDs is a EE-only attribute. For CE, use AssigneeID instead. AssigneeIDs *[]int64 `url:"assignee_ids,omitempty" json:"assignee_ids,omitempty"` MilestoneID *int64 `url:"milestone_id,omitempty" json:"milestone_id,omitempty"` Milestone *string `url:"milestone,omitempty" json:"milestone,omitempty"` Labels *LabelOptions `url:"labels,comma,omitempty" json:"labels,omitempty"` AddLabels *LabelOptions `url:"add_labels,comma,omitempty" json:"add_labels,omitempty"` RemoveLabels *LabelOptions `url:"remove_labels,comma,omitempty" json:"remove_labels,omitempty"` Loading @@ -463,10 +468,13 @@ type UpdateIssueOptions struct { Weight *int64 `url:"weight,omitempty" json:"weight,omitempty"` DiscussionLocked *bool `url:"discussion_locked,omitempty" json:"discussion_locked,omitempty"` IssueType *string `url:"issue_type,omitempty" json:"issue_type,omitempty"` Severity *string `url:"severity,omitempty" json:"severity,omitempty"` StartDate *ISOTime `url:"start_date,omitempty" json:"start_date,omitempty"` ResetDueDate bool `url:"-" json:"-"` ResetEpicID bool `url:"-" json:"-"` ResetMilestoneID bool `url:"-" json:"-"` ResetStartDate bool `url:"-" json:"-"` ResetWeight bool `url:"-" json:"-"` } Loading Loading @@ -515,6 +523,10 @@ func (o UpdateIssueOptions) MarshalJSON() ([]byte, error) { data["milestone_id"] = nil } if o.ResetStartDate { data["start_date"] = nil } if o.ResetWeight { data["weight"] = nil } Loading issues_test.go +54 −0 Changes for issues_test.go: 54 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -579,6 +579,40 @@ func TestCreateIssue(t *testing.T) { assert.Equal(t, want, issue) } func TestCreateIssue_milestoneSeverityStartDate(t *testing.T) { t.Parallel() mux, client := setup(t) mux.HandleFunc("/api/v4/projects/1/issues", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodPost) testBodyJSON(t, r, map[string]any{ "title": "Incident", "issue_type": "incident", "milestone": "v1.0", "severity": "high", "start_date": "2025-05-12", }) mustWriteJSONResponse(t, w, map[string]any{"id": 1, "title": "Incident"}) }) // GIVEN options with milestone title, severity and start date opt := &CreateIssueOptions{ Title: new("Incident"), IssueType: new("incident"), Milestone: new("v1.0"), Severity: new("high"), StartDate: new(ISOTime(time.Date(2025, time.May, 12, 0, 0, 0, 0, time.UTC))), } // WHEN creating the issue issue, resp, err := client.Issues.CreateIssue(1, opt) // THEN all three attributes are sent require.NoError(t, err) require.NotNil(t, resp) assert.Equal(t, int64(1), issue.ID) } func TestUpdateIssue(t *testing.T) { t.Parallel() mux, client := setup(t) Loading Loading @@ -669,6 +703,26 @@ func TestUpdateIssue_ResetFields(t *testing.T) { opts: UpdateIssueOptions{ResetWeight: true}, wantBody: map[string]any{"weight": nil}, }, { name: "set start date", opts: UpdateIssueOptions{StartDate: new(ISOTime(time.Date(2025, time.May, 12, 0, 0, 0, 0, time.UTC)))}, wantBody: map[string]any{"start_date": "2025-05-12"}, }, { name: "unset start date", opts: UpdateIssueOptions{ResetStartDate: true}, wantBody: map[string]any{"start_date": nil}, }, { name: "set milestone title", opts: UpdateIssueOptions{Milestone: new("v1.0")}, wantBody: map[string]any{"milestone": "v1.0"}, }, { name: "set severity", opts: UpdateIssueOptions{Severity: new("critical")}, wantBody: map[string]any{"severity": "critical"}, }, } for _, tt := range tests { Loading Loading
issues.go +14 −2 Changes for issues.go: 14 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -416,6 +416,7 @@ type CreateIssueOptions struct { // AssigneeIDs is a EE-only attribute. For CE, use AssigneeID instead. AssigneeIDs *[]int64 `url:"assignee_ids,omitempty" json:"assignee_ids,omitempty"` MilestoneID *int64 `url:"milestone_id,omitempty" json:"milestone_id,omitempty"` Milestone *string `url:"milestone,omitempty" json:"milestone,omitempty"` Labels *LabelOptions `url:"labels,comma,omitempty" json:"labels,omitempty"` CreatedAt *time.Time `url:"created_at,omitempty" json:"created_at,omitempty"` DueDate *ISOTime `url:"due_date,omitempty" json:"due_date,omitempty"` Loading @@ -424,6 +425,8 @@ type CreateIssueOptions struct { DiscussionToResolve *string `url:"discussion_to_resolve,omitempty" json:"discussion_to_resolve,omitempty"` Weight *int64 `url:"weight,omitempty" json:"weight,omitempty"` IssueType *string `url:"issue_type,omitempty" json:"issue_type,omitempty"` Severity *string `url:"severity,omitempty" json:"severity,omitempty"` StartDate *ISOTime `url:"start_date,omitempty" json:"start_date,omitempty"` } // CreateIssue creates a new project issue. Loading @@ -440,8 +443,9 @@ func (s *IssuesService) CreateIssue(pid any, opt *CreateIssueOptions, options .. // UpdateIssueOptions represents the available UpdateIssue() options. // // To reset the due date, epic, milestone, or weight of the issue, set the // ResetDueDate, ResetEpic, ResetMilestone, or ResetWeight field to true. // To reset the due date, epic, milestone, start date, or weight of the issue, // set the ResetDueDate, ResetEpicID, ResetMilestoneID, ResetStartDate, or // ResetWeight field to true. // // GitLab API docs: https://docs.gitlab.com/api/issues/#edit-an-issue type UpdateIssueOptions struct { Loading @@ -453,6 +457,7 @@ type UpdateIssueOptions struct { // AssigneeIDs is a EE-only attribute. For CE, use AssigneeID instead. AssigneeIDs *[]int64 `url:"assignee_ids,omitempty" json:"assignee_ids,omitempty"` MilestoneID *int64 `url:"milestone_id,omitempty" json:"milestone_id,omitempty"` Milestone *string `url:"milestone,omitempty" json:"milestone,omitempty"` Labels *LabelOptions `url:"labels,comma,omitempty" json:"labels,omitempty"` AddLabels *LabelOptions `url:"add_labels,comma,omitempty" json:"add_labels,omitempty"` RemoveLabels *LabelOptions `url:"remove_labels,comma,omitempty" json:"remove_labels,omitempty"` Loading @@ -463,10 +468,13 @@ type UpdateIssueOptions struct { Weight *int64 `url:"weight,omitempty" json:"weight,omitempty"` DiscussionLocked *bool `url:"discussion_locked,omitempty" json:"discussion_locked,omitempty"` IssueType *string `url:"issue_type,omitempty" json:"issue_type,omitempty"` Severity *string `url:"severity,omitempty" json:"severity,omitempty"` StartDate *ISOTime `url:"start_date,omitempty" json:"start_date,omitempty"` ResetDueDate bool `url:"-" json:"-"` ResetEpicID bool `url:"-" json:"-"` ResetMilestoneID bool `url:"-" json:"-"` ResetStartDate bool `url:"-" json:"-"` ResetWeight bool `url:"-" json:"-"` } Loading Loading @@ -515,6 +523,10 @@ func (o UpdateIssueOptions) MarshalJSON() ([]byte, error) { data["milestone_id"] = nil } if o.ResetStartDate { data["start_date"] = nil } if o.ResetWeight { data["weight"] = nil } Loading
issues_test.go +54 −0 Changes for issues_test.go: 54 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -579,6 +579,40 @@ func TestCreateIssue(t *testing.T) { assert.Equal(t, want, issue) } func TestCreateIssue_milestoneSeverityStartDate(t *testing.T) { t.Parallel() mux, client := setup(t) mux.HandleFunc("/api/v4/projects/1/issues", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodPost) testBodyJSON(t, r, map[string]any{ "title": "Incident", "issue_type": "incident", "milestone": "v1.0", "severity": "high", "start_date": "2025-05-12", }) mustWriteJSONResponse(t, w, map[string]any{"id": 1, "title": "Incident"}) }) // GIVEN options with milestone title, severity and start date opt := &CreateIssueOptions{ Title: new("Incident"), IssueType: new("incident"), Milestone: new("v1.0"), Severity: new("high"), StartDate: new(ISOTime(time.Date(2025, time.May, 12, 0, 0, 0, 0, time.UTC))), } // WHEN creating the issue issue, resp, err := client.Issues.CreateIssue(1, opt) // THEN all three attributes are sent require.NoError(t, err) require.NotNil(t, resp) assert.Equal(t, int64(1), issue.ID) } func TestUpdateIssue(t *testing.T) { t.Parallel() mux, client := setup(t) Loading Loading @@ -669,6 +703,26 @@ func TestUpdateIssue_ResetFields(t *testing.T) { opts: UpdateIssueOptions{ResetWeight: true}, wantBody: map[string]any{"weight": nil}, }, { name: "set start date", opts: UpdateIssueOptions{StartDate: new(ISOTime(time.Date(2025, time.May, 12, 0, 0, 0, 0, time.UTC)))}, wantBody: map[string]any{"start_date": "2025-05-12"}, }, { name: "unset start date", opts: UpdateIssueOptions{ResetStartDate: true}, wantBody: map[string]any{"start_date": nil}, }, { name: "set milestone title", opts: UpdateIssueOptions{Milestone: new("v1.0")}, wantBody: map[string]any{"milestone": "v1.0"}, }, { name: "set severity", opts: UpdateIssueOptions{Severity: new("critical")}, wantBody: map[string]any{"severity": "critical"}, }, } for _, tt := range tests { Loading