summaryrefslogtreecommitdiffstats
path: root/pkg/git
diff options
context:
space:
mode:
authorAndrei Miulescu <lusu777@gmail.com>2018-08-12 21:04:47 +1000
committerAndrei Miulescu <lusu777@gmail.com>2018-08-12 21:04:47 +1000
commite8eb78617c17d8b743fcb17c0790c42e11cd5db5 (patch)
tree44f4f66047b7be5217d77f7fb34e34fb750e7f99 /pkg/git
parente65ddd7b6facfaf3ebc8b022f26066bdf96a28b0 (diff)
Mid refactor change some more stuff
Diffstat (limited to 'pkg/git')
-rw-r--r--pkg/git/branch.go6
-rw-r--r--pkg/git/branch_list_builder.go20
-rw-r--r--pkg/git/git_structs.go28
3 files changed, 15 insertions, 39 deletions
diff --git a/pkg/git/branch.go b/pkg/git/branch.go
index e0fd75a73..78a52bbc8 100644
--- a/pkg/git/branch.go
+++ b/pkg/git/branch.go
@@ -6,12 +6,6 @@ import (
"github.com/fatih/color"
)
-// Branch : A git branch
-type Branch struct {
- Name string
- Recency string
-}
-
// GetDisplayString returns the dispaly string of branch
// func (b *Branch) GetDisplayString() string {
// return gui.withPadding(b.Recency, 4) + gui.coloredString(b.Name, b.getColor())
diff --git a/pkg/git/branch_list_builder.go b/pkg/git/branch_list_builder.go
index 1abf11fcc..2f80dba32 100644
--- a/pkg/git/branch_list_builder.go
+++ b/pkg/git/branch_list_builder.go
@@ -4,6 +4,10 @@ import (
"regexp"
"strings"
+ "github.com/jesseduffield/lazygit/pkg/commands"
+
+ "github.com/Sirupsen/logrus"
+
"gopkg.in/src-d/go-git.v4/plumbing"
)
@@ -15,20 +19,26 @@ import (
// our safe branches, then add the remaining safe branches, ensuring uniqueness
// along the way
-type branchListBuilder struct{}
+type BranchListBuilder struct {
+ Log *logrus.Log
+ GitCommand *commands.GitCommand
+}
-func newBranchListBuilder() *branchListBuilder {
- return &branchListBuilder{}
+func NewBranchListBuilder(log *logrus.Logger, gitCommand *GitCommand) (*BranchListBuilder, error) {
+ return nil, &BranchListBuilder{
+ Log: log,
+ GitCommand: gitCommand
+ }
}
-func (b *branchListBuilder) obtainCurrentBranch() Branch {
+func (b *branchListBuilder) ObtainCurrentBranch() Branch {
// I used go-git for this, but that breaks if you've just done a git init,
// even though you're on 'master'
branchName, _ := runDirectCommand("git symbolic-ref --short HEAD")
return Branch{Name: strings.TrimSpace(branchName), Recency: " *"}
}
-func (*branchListBuilder) obtainReflogBranches() []Branch {
+func (*branchListBuilder) ObtainReflogBranches() []Branch {
branches := make([]Branch, 0)
rawString, err := runDirectCommand("git reflog -n100 --pretty='%cr|%gs' --grep-reflog='checkout: moving' HEAD")
if err != nil {
diff --git a/pkg/git/git_structs.go b/pkg/git/git_structs.go
deleted file mode 100644
index 711f25f4b..000000000
--- a/pkg/git/git_structs.go
+++ /dev/null
@@ -1,28 +0,0 @@
-package git
-
-// File : A staged/unstaged file
-// TODO: decide whether to give all of these the Git prefix
-type File struct {
- Name string
- HasStagedChanges bool
- HasUnstagedChanges bool
- Tracked bool
- Deleted bool
- HasMergeConflicts bool
- DisplayString string
-}
-
-// Commit : A git commit
-type Commit struct {
- Sha string
- Name string
- Pushed bool
- DisplayString string
-}
-
-// StashEntry : A git stash entry
-type StashEntry struct {
- Index int
- Name string
- DisplayString string
-}