Skip to content

Commit 15f8ad3

Browse files
committed
Cleanup: use nil for empty slice
1 parent 26f2c02 commit 15f8ad3

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

pkg/commands/git_commands/commit_loader.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ func (self *CommitLoader) extractCommitFromLine(hashPool *utils.StringPool, line
214214
}
215215
message := split[7]
216216

217-
tags := []string{}
217+
var tags []string
218218

219219
if extraInfo != "" {
220220
extraInfoFields := strings.Split(extraInfo, ",")

pkg/commands/git_commands/commit_loader_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func TestGetCommits(t *testing.T) {
8686
Name: "better typing for rebase mode",
8787
Status: models.StatusUnpushed,
8888
Action: models.ActionNone,
89-
Tags: []string{},
89+
Tags: nil,
9090
ExtraInfo: "(HEAD -> better-tests)",
9191
AuthorName: "Jesse Duffield",
9292
AuthorEmail: "[email protected]",
@@ -100,7 +100,7 @@ func TestGetCommits(t *testing.T) {
100100
Name: "fix logging",
101101
Status: models.StatusPushed,
102102
Action: models.ActionNone,
103-
Tags: []string{},
103+
Tags: nil,
104104
ExtraInfo: "(origin/better-tests)",
105105
AuthorName: "Jesse Duffield",
106106
AuthorEmail: "[email protected]",
@@ -128,7 +128,7 @@ func TestGetCommits(t *testing.T) {
128128
Name: "WIP",
129129
Status: models.StatusPushed,
130130
Action: models.ActionNone,
131-
Tags: []string{},
131+
Tags: nil,
132132
ExtraInfo: "",
133133
AuthorName: "Jesse Duffield",
134134
AuthorEmail: "[email protected]",
@@ -142,7 +142,7 @@ func TestGetCommits(t *testing.T) {
142142
Name: "WIP",
143143
Status: models.StatusPushed,
144144
Action: models.ActionNone,
145-
Tags: []string{},
145+
Tags: nil,
146146
ExtraInfo: "",
147147
AuthorName: "Jesse Duffield",
148148
AuthorEmail: "[email protected]",
@@ -156,7 +156,7 @@ func TestGetCommits(t *testing.T) {
156156
Name: "WIP",
157157
Status: models.StatusMerged,
158158
Action: models.ActionNone,
159-
Tags: []string{},
159+
Tags: nil,
160160
ExtraInfo: "",
161161
AuthorName: "Jesse Duffield",
162162
AuthorEmail: "[email protected]",
@@ -170,7 +170,7 @@ func TestGetCommits(t *testing.T) {
170170
Name: "WIP",
171171
Status: models.StatusMerged,
172172
Action: models.ActionNone,
173-
Tags: []string{},
173+
Tags: nil,
174174
ExtraInfo: "",
175175
AuthorName: "Jesse Duffield",
176176
AuthorEmail: "[email protected]",
@@ -184,7 +184,7 @@ func TestGetCommits(t *testing.T) {
184184
Name: "refactoring the config struct",
185185
Status: models.StatusMerged,
186186
Action: models.ActionNone,
187-
Tags: []string{},
187+
Tags: nil,
188188
ExtraInfo: "",
189189
AuthorName: "Jesse Duffield",
190190
AuthorEmail: "[email protected]",
@@ -220,7 +220,7 @@ func TestGetCommits(t *testing.T) {
220220
Name: "better typing for rebase mode",
221221
Status: models.StatusUnpushed,
222222
Action: models.ActionNone,
223-
Tags: []string{},
223+
Tags: nil,
224224
ExtraInfo: "(HEAD -> better-tests)",
225225
AuthorName: "Jesse Duffield",
226226
AuthorEmail: "[email protected]",
@@ -258,7 +258,7 @@ func TestGetCommits(t *testing.T) {
258258
Name: "better typing for rebase mode",
259259
Status: models.StatusUnpushed,
260260
Action: models.ActionNone,
261-
Tags: []string{},
261+
Tags: nil,
262262
ExtraInfo: "(HEAD -> better-tests)",
263263
AuthorName: "Jesse Duffield",
264264
AuthorEmail: "[email protected]",

0 commit comments

Comments
 (0)