X Tutup
Skip to content

Commit 4c2f15f

Browse files
committed
Roll back the place of colorFuncForState
1 parent 0095fe9 commit 4c2f15f

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

command/issue.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ func issueView(cmd *cobra.Command, args []string) error {
229229
}
230230

231231
func issueStateTitleWithColor(state string) string {
232-
colorFunc := utils.ColorFuncForState(state)
232+
colorFunc := colorFuncForState(state)
233233
return colorFunc(strings.Title(strings.ToLower(state)))
234234
}
235235

@@ -425,7 +425,7 @@ func printIssues(w io.Writer, prefix string, totalCount int, issues []api.Issue)
425425
}
426426
now := time.Now()
427427
ago := now.Sub(issue.UpdatedAt)
428-
table.AddField(issueNum, nil, utils.ColorFuncForState(issue.State))
428+
table.AddField(issueNum, nil, colorFuncForState(issue.State))
429429
table.AddField(replaceExcessiveWhitespace(issue.Title), nil, nil)
430430
table.AddField(labels, nil, utils.Gray)
431431
table.AddField(utils.FuzzyAgo(ago), nil, utils.Gray)

command/pr.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,21 @@ func colorFuncForPR(pr api.PullRequest) func(string) string {
238238
if pr.State == "OPEN" && pr.IsDraft {
239239
return utils.Gray
240240
}
241-
return utils.ColorFuncForState(pr.State)
241+
return colorFuncForState(pr.State)
242+
}
243+
244+
// colorFuncForState returns a color function for a PR/Issue state
245+
func colorFuncForState(state string) func(string) string {
246+
switch state {
247+
case "OPEN":
248+
return utils.Green
249+
case "CLOSED":
250+
return utils.Red
251+
case "MERGED":
252+
return utils.Magenta
253+
default:
254+
return nil
255+
}
242256
}
243257

244258
func prView(cmd *cobra.Command, args []string) error {

utils/utils.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,3 @@ func Spinner(w io.Writer) *spinner.Spinner {
7575
s.Writer = w
7676
return s
7777
}
78-
79-
// ColorFuncForState returns a color function for a PR/Issue state
80-
func ColorFuncForState(state string) func(string) string {
81-
switch state {
82-
case "OPEN":
83-
return Green
84-
case "CLOSED":
85-
return Red
86-
case "MERGED":
87-
return Magenta
88-
default:
89-
return nil
90-
}
91-
}

0 commit comments

Comments
 (0)
X Tutup