Skip to content

Commit 34ca626

Browse files
committed
Use a better solution for bools, and update all usage of them
Signed-off-by: rtweed <[email protected]>
1 parent 520b63a commit 34ca626

File tree

8 files changed

+77
-21
lines changed

8 files changed

+77
-21
lines changed

cloud/filter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ type Filter struct {
3737

3838
// GetMyFiltersQueryOptions specifies the optional parameters for the Get My Filters method
3939
type GetMyFiltersQueryOptions struct {
40-
IncludeFavourites bool `url:"includeFavourites,omitempty"`
40+
IncludeFavourites *bool `url:"includeFavourites,omitempty"`
4141
Expand string `url:"expand,omitempty"`
4242
}
4343

cloud/issue.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ type IssueService service
3131

3232
// UpdateQueryOptions specifies the optional parameters to the Edit issue
3333
type UpdateQueryOptions struct {
34-
NotifyUsers bool `url:"notifyUsers"` // can't be omitted as this means it's omitted when false which isn't desired as this defaults to true
35-
OverrideScreenSecurity bool `url:"overrideScreenSecurity,omitempty"`
36-
OverrideEditableFlag bool `url:"overrideEditableFlag,omitempty"`
34+
NotifyUsers *bool `url:"notifyUsers,omitempty"`
35+
OverrideScreenSecurity *bool `url:"overrideScreenSecurity,omitempty"`
36+
OverrideEditableFlag *bool `url:"overrideEditableFlag,omitempty"`
3737
}
3838

3939
// Issue represents a Jira issue.
@@ -545,8 +545,8 @@ type GetQueryOptions struct {
545545
// Properties is the list of properties to return for the issue. By default no properties are returned.
546546
Properties string `url:"properties,omitempty"`
547547
// FieldsByKeys if true then fields in issues will be referenced by keys instead of ids
548-
FieldsByKeys bool `url:"fieldsByKeys,omitempty"`
549-
UpdateHistory bool `url:"updateHistory,omitempty"`
548+
FieldsByKeys *bool `url:"fieldsByKeys,omitempty"`
549+
UpdateHistory *bool `url:"updateHistory,omitempty"`
550550
ProjectKeys string `url:"projectKeys,omitempty"`
551551
}
552552

@@ -559,12 +559,12 @@ type GetWorklogsQueryOptions struct {
559559
}
560560

561561
type AddWorklogQueryOptions struct {
562-
NotifyUsers bool `url:"notifyUsers"` // can't be omitted as this means it's omitted when false which isn't desired as this defaults to true
562+
NotifyUsers *bool `url:"notifyUsers",omitempty`
563563
AdjustEstimate string `url:"adjustEstimate,omitempty"`
564564
NewEstimate string `url:"newEstimate,omitempty"`
565565
ReduceBy string `url:"reduceBy,omitempty"`
566566
Expand string `url:"expand,omitempty"`
567-
OverrideEditableFlag bool `url:"overrideEditableFlag,omitempty"`
567+
OverrideEditableFlag *bool `url:"overrideEditableFlag,omitempty"`
568568
}
569569

570570
// CustomFields represents custom fields of Jira

cloud/issue_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@ func TestIssueService_UpdateIssueWithOptions(t *testing.T) {
192192
i := make(map[string]interface{})
193193
fields := make(map[string]interface{})
194194
i["fields"] = fields
195-
resp, err := testClient.Issue.client.Issue.UpdateIssueWithOptions(context.Background(), jID, i, &UpdateQueryOptions{NotifyUsers: false})
195+
196+
resp, err := testClient.Issue.client.Issue.UpdateIssueWithOptions(context.Background(), jID, i, &UpdateQueryOptions{NotifyUsers: Bool(true)})
196197
if resp == nil {
197198
t.Error("Expected resp. resp is nil")
198199
}

cloud/jira_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func testRequestParams(t *testing.T, r *http.Request, want map[string]string) {
7474
}
7575

7676
func Test_addOptions(t *testing.T) {
77-
v, err := addOptions("rest/api/2/issue/123", &UpdateQueryOptions{NotifyUsers: false})
77+
v, err := addOptions("rest/api/2/issue/123", &UpdateQueryOptions{NotifyUsers: Bool(false)})
7878
if err != nil {
7979
t.Errorf("Expected no error. Got: %+v", err)
8080
}

onpremise/.config/dlv/config.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Configuration file for the delve debugger.
2+
3+
# This is the default configuration file. Available options are provided, but disabled.
4+
# Delete the leading hash mark to enable an item.
5+
6+
# Uncomment the following line and set your preferred ANSI color for source
7+
# line numbers in the (list) command. The default is 34 (dark blue). See
8+
# https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit
9+
# source-list-line-color: "\x1b[34m"
10+
11+
# Uncomment the following lines to change the colors used by syntax highlighting.
12+
# source-list-keyword-color: "\x1b[0m"
13+
# source-list-string-color: "\x1b[92m"
14+
# source-list-number-color: "\x1b[0m"
15+
# source-list-comment-color: "\x1b[95m"
16+
# source-list-arrow-color: "\x1b[93m"
17+
# source-list-tab-color: "\x1b[90m"
18+
19+
# Uncomment to change what is printed instead of '\t'.
20+
# tab: "... "
21+
22+
# Uncomment to change the number of lines printed above and below cursor when
23+
# listing source code.
24+
# source-list-line-count: 5
25+
26+
# Provided aliases will be added to the default aliases for a given command.
27+
aliases:
28+
# command: ["alias1", "alias2"]
29+
30+
# Define sources path substitution rules. Can be used to rewrite a source path stored
31+
# in program's debug information, if the sources were moved to a different place
32+
# between compilation and debugging.
33+
# Note that substitution rules will not be used for paths passed to "break" and "trace"
34+
# commands.
35+
# See also Documentation/cli/substitutepath.md.
36+
substitute-path:
37+
# - {from: path, to: path}
38+
39+
# Maximum number of elements loaded from an array.
40+
# max-array-values: 64
41+
42+
# Maximum loaded string length.
43+
# max-string-len: 64
44+
45+
# Output evaluation.
46+
# max-variable-recurse: 1
47+
48+
# Uncomment the following line to make the whatis command also print the DWARF location expression of its argument.
49+
# show-location-expr: true
50+
51+
# Allow user to specify output syntax flavor of assembly, one of this list "intel"(default), "gnu", "go".
52+
# disassemble-flavor: intel
53+
54+
# List of directories to use when searching for separate debug info files.
55+
debug-info-directories: ["/usr/lib/debug/.build-id"]

onpremise/filter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ type Filter struct {
3737

3838
// GetMyFiltersQueryOptions specifies the optional parameters for the Get My Filters method
3939
type GetMyFiltersQueryOptions struct {
40-
IncludeFavourites bool `url:"includeFavourites,omitempty"`
40+
IncludeFavourites *bool `url:"includeFavourites,omitempty"`
4141
Expand string `url:"expand,omitempty"`
4242
}
4343

onpremise/issue.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ type IssueService service
3131

3232
// UpdateQueryOptions specifies the optional parameters to the Edit issue
3333
type UpdateQueryOptions struct {
34-
NotifyUsers bool `url:"notifyUsers"` // can't be omitted as this means it's omitted when false which isn't desired as this defaults to true
35-
OverrideScreenSecurity bool `url:"overrideScreenSecurity,omitempty"`
36-
OverrideEditableFlag bool `url:"overrideEditableFlag,omitempty"`
34+
NotifyUsers *bool `url:"notifyUsers,omitempty"`
35+
OverrideScreenSecurity *bool `url:"overrideScreenSecurity,omitempty"`
36+
OverrideEditableFlag *bool `url:"overrideEditableFlag,omitempty"`
3737
}
3838

3939
// Issue represents a Jira issue.
@@ -544,8 +544,8 @@ type GetQueryOptions struct {
544544
// Properties is the list of properties to return for the issue. By default no properties are returned.
545545
Properties string `url:"properties,omitempty"`
546546
// FieldsByKeys if true then fields in issues will be referenced by keys instead of ids
547-
FieldsByKeys bool `url:"fieldsByKeys,omitempty"`
548-
UpdateHistory bool `url:"updateHistory,omitempty"`
547+
FieldsByKeys *bool `url:"fieldsByKeys,omitempty"`
548+
UpdateHistory *bool `url:"updateHistory,omitempty"`
549549
ProjectKeys string `url:"projectKeys,omitempty"`
550550
}
551551

@@ -558,12 +558,12 @@ type GetWorklogsQueryOptions struct {
558558
}
559559

560560
type AddWorklogQueryOptions struct {
561-
NotifyUsers bool `url:"notifyUsers,omitempty"`
561+
NotifyUsers *bool `url:"notifyUsers,omitempty"`
562562
AdjustEstimate string `url:"adjustEstimate,omitempty"`
563563
NewEstimate string `url:"newEstimate,omitempty"`
564564
ReduceBy string `url:"reduceBy,omitempty"`
565565
Expand string `url:"expand,omitempty"`
566-
OverrideEditableFlag bool `url:"overrideEditableFlag,omitempty"`
566+
OverrideEditableFlag *bool `url:"overrideEditableFlag,omitempty"`
567567
}
568568

569569
// CustomFields represents custom fields of Jira
@@ -839,7 +839,7 @@ func (s *IssueService) Create(ctx context.Context, issue *Issue) (*Issue, *Respo
839839
// This double check effort is done for v2 - Remove this two lines if this is completed.
840840
func (s *IssueService) Update(ctx context.Context, issue *Issue, opts *UpdateQueryOptions) (*Issue, *Response, error) {
841841
apiEndpoint := fmt.Sprintf("rest/api/2/issue/%v", issue.Key)
842-
url, err := addOptions(apiEndpoint, *opts)
842+
url, err := addOptions(apiEndpoint, opts)
843843
if err != nil {
844844
return nil, nil, err
845845
}

onpremise/issue_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ func TestIssueService_Update_with_false_opts(t *testing.T) {
172172
Description: "example bug report",
173173
},
174174
}
175-
issue, _, err := testClient.Issue.Update(context.Background(), i, &UpdateQueryOptions{NotifyUsers: false})
175+
issue, _, err := testClient.Issue.Update(context.Background(), i, &UpdateQueryOptions{NotifyUsers: Bool(false)})
176176
if issue == nil {
177177
t.Error("Expected issue. Issue is nil")
178178
}
@@ -199,7 +199,7 @@ func TestIssueService_Update_with_multiple_opts(t *testing.T) {
199199
Description: "example bug report",
200200
},
201201
}
202-
issue, _, err := testClient.Issue.Update(context.Background(), i, &UpdateQueryOptions{NotifyUsers: false, OverrideScreenSecurity: true})
202+
issue, _, err := testClient.Issue.Update(context.Background(), i, &UpdateQueryOptions{NotifyUsers: Bool(false), OverrideScreenSecurity: Bool(true)})
203203
if issue == nil {
204204
t.Error("Expected issue. Issue is nil")
205205
}

0 commit comments

Comments
 (0)