summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Haller <stefan@haller-berlin.de>2024-04-27 11:09:38 +0200
committerStefan Haller <stefan@haller-berlin.de>2024-04-27 11:31:19 +0200
commitb63321a30293e8c9750f6f59390bfe0d1677ab8c (patch)
tree40414eeae5f34193c1029a026b7fc388847f2ed9
parenta4354ccdfb25cac9f4928823dae86336c7571664 (diff)
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.
-rw-r--r--pkg/gui/presentation/commits.go30
1 files changed, 18 insertions, 12 deletions
diff --git a/pkg/gui/presentation/commits.go b/pkg/gui/presentation/commits.go
index e3867430f..cff36bf30 100644
--- a/pkg/gui/presentation/commits.go
+++ b/pkg/gui/presentation/commits.go
@@ -325,6 +325,20 @@ func displayCommit(
hashString = hashColor.Sprint("*")
}
+ divergenceString := ""
+ if commit.Divergence != models.DivergenceNone {
+ divergenceString = hashColor.Sprint(lo.Ternary(commit.Divergence == models.DivergenceLeft, "↑", "↓"))
+ } else if icons.IsIconEnabled() {
+ divergenceString = hashColor.Sprint(icons.IconForCommit(commit))
+ }
+
+ descriptionString := ""
+ if fullDescription {
+ descriptionString = style.FgBlue.Sprint(
+ utils.UnixToDateSmart(now, commit.UnixTimestamp, timeFormat, shortTimeFormat),
+ )
+ }
+
actionString := ""
if commit.Action != models.ActionNone {
todoString := lo.Ternary(commit.Action == models.ActionConflict, "conflict", commit.Action.String())
@@ -378,20 +392,12 @@ func displayCommit(
}
cols := make([]string, 0, 7)
- if commit.Divergence != models.DivergenceNone {
- cols = append(cols, hashColor.Sprint(lo.Ternary(commit.Divergence == models.DivergenceLeft, "↑", "↓")))
- } else if icons.IsIconEnabled() {
- cols = append(cols, hashColor.Sprint(icons.IconForCommit(commit)))
- }
- cols = append(cols, hashString)
- cols = append(cols, bisectString)
- if fullDescription {
- cols = append(cols, style.FgBlue.Sprint(
- utils.UnixToDateSmart(now, commit.UnixTimestamp, timeFormat, shortTimeFormat),
- ))
- }
cols = append(
cols,
+ divergenceString,
+ hashString,
+ bisectString,
+ descriptionString,
actionString,
authorFunc(commit.AuthorName),
graphLine+mark+tagString+theme.DefaultTextColor.Sprint(name),