mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-11 04:15:48 +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:
parent
a4354ccdfb
commit
b63321a302
1 changed files with 18 additions and 12 deletions
|
@ -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),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue