From e8eb78617c17d8b743fcb17c0790c42e11cd5db5 Mon Sep 17 00:00:00 2001 From: Andrei Miulescu Date: Sun, 12 Aug 2018 21:04:47 +1000 Subject: Mid refactor change some more stuff --- pkg/git/branch.go | 6 ------ pkg/git/branch_list_builder.go | 20 +++++++++++++++----- pkg/git/git_structs.go | 28 ---------------------------- 3 files changed, 15 insertions(+), 39 deletions(-) delete mode 100644 pkg/git/git_structs.go (limited to 'pkg/git') 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 -} -- cgit v1.2.3