summaryrefslogtreecommitdiffstats
path: root/pkg/gui/presentation
diff options
context:
space:
mode:
authorStefan Haller <stefan@haller-berlin.de>2023-10-14 15:31:13 +0200
committerStefan Haller <stefan@haller-berlin.de>2023-10-16 09:03:07 +0200
commit23befdd13a94c1880cd9df4db19719e681ca3eb4 (patch)
tree30f4bbdbc685775187c96f3dd291b6a26891b7a7 /pkg/gui/presentation
parent58a83b08627e1488ff99cf80fd3ab2d28af90104 (diff)
Pass "now" into utils.Loader
This makes it possible to write deterministic tests for views that use it.
Diffstat (limited to 'pkg/gui/presentation')
-rw-r--r--pkg/gui/presentation/branches.go10
-rw-r--r--pkg/gui/presentation/tags.go4
2 files changed, 9 insertions, 5 deletions
diff --git a/pkg/gui/presentation/branches.go b/pkg/gui/presentation/branches.go
index bd027ca62..22512aca2 100644
--- a/pkg/gui/presentation/branches.go
+++ b/pkg/gui/presentation/branches.go
@@ -3,6 +3,7 @@ package presentation
import (
"fmt"
"strings"
+ "time"
"github.com/jesseduffield/lazygit/pkg/commands/git_commands"
"github.com/jesseduffield/lazygit/pkg/commands/models"
@@ -29,7 +30,7 @@ func GetBranchListDisplayStrings(
) [][]string {
return lo.Map(branches, func(branch *models.Branch, _ int) []string {
diffed := branch.Name == diffName
- return getBranchDisplayStrings(branch, getItemOperation(branch), fullDescription, diffed, tr, userConfig, worktrees)
+ return getBranchDisplayStrings(branch, getItemOperation(branch), fullDescription, diffed, tr, userConfig, worktrees, time.Now())
})
}
@@ -42,6 +43,7 @@ func getBranchDisplayStrings(
tr *i18n.TranslationSet,
userConfig *config.UserConfig,
worktrees []*models.Worktree,
+ now time.Time,
) []string {
displayName := b.Name
if b.DisplayName != "" {
@@ -124,13 +126,13 @@ func ColoredBranchStatus(branch *models.Branch, itemOperation types.ItemOperatio
colour = style.FgMagenta
}
- return colour.Sprint(BranchStatus(branch, itemOperation, tr))
+ return colour.Sprint(BranchStatus(branch, itemOperation, tr, time.Now()))
}
-func BranchStatus(branch *models.Branch, itemOperation types.ItemOperation, tr *i18n.TranslationSet) string {
+func BranchStatus(branch *models.Branch, itemOperation types.ItemOperation, tr *i18n.TranslationSet, now time.Time) string {
itemOperationStr := itemOperationToString(itemOperation, tr)
if itemOperationStr != "" {
- return itemOperationStr + " " + utils.Loader()
+ return itemOperationStr + " " + utils.Loader(now)
}
if !branch.IsTrackingRemote() {
diff --git a/pkg/gui/presentation/tags.go b/pkg/gui/presentation/tags.go
index 9bdabcf40..c210bdebc 100644
--- a/pkg/gui/presentation/tags.go
+++ b/pkg/gui/presentation/tags.go
@@ -1,6 +1,8 @@
package presentation
import (
+ "time"
+
"github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/jesseduffield/lazygit/pkg/gui/presentation/icons"
"github.com/jesseduffield/lazygit/pkg/gui/style"
@@ -37,7 +39,7 @@ func getTagDisplayStrings(t *models.Tag, itemOperation types.ItemOperation, diff
descriptionStr := descriptionColor.Sprint(t.Description())
itemOperationStr := itemOperationToString(itemOperation, tr)
if itemOperationStr != "" {
- descriptionStr = style.FgCyan.Sprint(itemOperationStr+" "+utils.Loader()) + " " + descriptionStr
+ descriptionStr = style.FgCyan.Sprint(itemOperationStr+" "+utils.Loader(time.Now())) + " " + descriptionStr
}
res = append(res, textStyle.Sprint(t.Name), descriptionStr)
return res