Skip to content

Commit b63321a

Browse files
committed
Refactor pkg/gui/presentation/commits.go slightly to be consistent
Change `func displayCommit()` so all the individual strings are built first, then the whole thing `cols` is put together. Before, most strings were built prior to constructing `cols`, but a few were built inside the `cols` construction.
1 parent a4354cc commit b63321a

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

pkg/gui/presentation/commits.go

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,20 @@ func displayCommit(
325325
hashString = hashColor.Sprint("*")
326326
}
327327

328+
divergenceString := ""
329+
if commit.Divergence != models.DivergenceNone {
330+
divergenceString = hashColor.Sprint(lo.Ternary(commit.Divergence == models.DivergenceLeft, "↑", "↓"))
331+
} else if icons.IsIconEnabled() {
332+
divergenceString = hashColor.Sprint(icons.IconForCommit(commit))
333+
}
334+
335+
descriptionString := ""
336+
if fullDescription {
337+
descriptionString = style.FgBlue.Sprint(
338+
utils.UnixToDateSmart(now, commit.UnixTimestamp, timeFormat, shortTimeFormat),
339+
)
340+
}
341+
328342
actionString := ""
329343
if commit.Action != models.ActionNone {
330344
todoString := lo.Ternary(commit.Action == models.ActionConflict, "conflict", commit.Action.String())
@@ -378,20 +392,12 @@ func displayCommit(
378392
}
379393

380394
cols := make([]string, 0, 7)
381-
if commit.Divergence != models.DivergenceNone {
382-
cols = append(cols, hashColor.Sprint(lo.Ternary(commit.Divergence == models.DivergenceLeft, "↑", "↓")))
383-
} else if icons.IsIconEnabled() {
384-
cols = append(cols, hashColor.Sprint(icons.IconForCommit(commit)))
385-
}
386-
cols = append(cols, hashString)
387-
cols = append(cols, bisectString)
388-
if fullDescription {
389-
cols = append(cols, style.FgBlue.Sprint(
390-
utils.UnixToDateSmart(now, commit.UnixTimestamp, timeFormat, shortTimeFormat),
391-
))
392-
}
393395
cols = append(
394396
cols,
397+
divergenceString,
398+
hashString,
399+
bisectString,
400+
descriptionString,
395401
actionString,
396402
authorFunc(commit.AuthorName),
397403
graphLine+mark+tagString+theme.DefaultTextColor.Sprint(name),

0 commit comments

Comments
 (0)