summaryrefslogtreecommitdiffstats
path: root/pkg/commands/branch.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2018-08-13 20:26:02 +1000
committerJesse Duffield <jessedduffield@gmail.com>2018-08-13 20:26:02 +1000
commit97cff656121270e9c790432e28622d92ab7b0f1a (patch)
tree7425013e94dc0a19699b48bde6bb20c6f5b86c8a /pkg/commands/branch.go
parentf9c39ad64bddd1577636c0ce5606eda44bc704ef (diff)
progress on refactor
Diffstat (limited to 'pkg/commands/branch.go')
-rw-r--r--pkg/commands/branch.go39
1 files changed, 39 insertions, 0 deletions
diff --git a/pkg/commands/branch.go b/pkg/commands/branch.go
new file mode 100644
index 000000000..13c26e766
--- /dev/null
+++ b/pkg/commands/branch.go
@@ -0,0 +1,39 @@
+package commands
+
+import (
+ "strings"
+
+ "github.com/fatih/color"
+ "github.com/jesseduffield/lazygit/pkg/utils"
+)
+
+// Branch : A git branch
+// duplicating this for now
+type Branch struct {
+ Name string
+ Recency string
+}
+
+// GetDisplayString returns the dispaly string of branch
+func (b *Branch) GetDisplayString() string {
+ return utils.WithPadding(b.Recency, 4) + utils.ColoredString(b.Name, b.GetColor())
+}
+
+// GetColor branch color
+func (b *Branch) GetColor() color.Attribute {
+ switch b.getType() {
+ case "feature":
+ return color.FgGreen
+ case "bugfix":
+ return color.FgYellow
+ case "hotfix":
+ return color.FgRed
+ default:
+ return color.FgWhite
+ }
+}
+
+// expected to return feature/bugfix/hotfix or blank string
+func (b *Branch) getType() string {
+ return strings.Split(b.Name, "/")[0]
+}