mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-15 00:15:32 +02:00
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.
This commit is contained in:
@ -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),
|
||||
|
Reference in New Issue
Block a user