diff options
| author | Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com> | 2018-12-06 01:03:26 +0300 |
|---|---|---|
| committer | Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com> | 2018-12-06 01:03:26 +0300 |
| commit | ee8527fbb298c37d9a800f2a86402ce11245fe6b (patch) | |
| tree | cfc6b94e13489585e6461040f395f0b3143aa338 | |
| parent | application controls are overhauled (diff) | |
| download | gitbatch-ee8527fbb298c37d9a800f2a86402ce11245fe6b.tar.gz | |
not pushed commits highlighted in commits panel
| -rw-r--r-- | pkg/git/branch.go | 9 | ||||
| -rw-r--r-- | pkg/git/commit.go | 15 | ||||
| -rw-r--r-- | pkg/gui/commitsview.go | 4 |
3 files changed, 26 insertions, 2 deletions
diff --git a/pkg/git/branch.go b/pkg/git/branch.go index 0c8017f..204ddb2 100644 --- a/pkg/git/branch.go +++ b/pkg/git/branch.go @@ -167,3 +167,12 @@ func (entity *RepoEntity) pullDiffsToUpstream() ([]*Commit, error) { } return remoteCommits, nil } + +func (entity *RepoEntity) pushDiffsToUpstream() ([]string, error) { + sliced := make([]string, 0) + hashes := UpstreamPushDiffs(entity.AbsPath) + if hashes != "?" { + sliced = strings.Split(hashes, "\n") + } + return sliced, nil +} diff --git a/pkg/git/commit.go b/pkg/git/commit.go index ba0997e..13b0f54 100644 --- a/pkg/git/commit.go +++ b/pkg/git/commit.go @@ -27,6 +27,8 @@ const ( // LocalCommit is the commit that recorded locally LocalCommit CommitType = "local" // RemoteCommit is the commit that not merged to local branch + EvenCommit CommitType = "even" + // RemoteCommit is the commit that not merged to local branch RemoteCommit CommitType = "remote" ) @@ -92,15 +94,26 @@ func (entity *RepoEntity) loadCommits() error { for _, rmc := range rmcs { entity.Commits = append(entity.Commits, rmc) } + lcs, err := entity.pushDiffsToUpstream() + if err != nil { + log.Trace("git rev-list failed " + err.Error()) + return err + } // ... just iterates over the commits err = cIter.ForEach(func(c *object.Commit) error { re := regexp.MustCompile(`\r?\n`) + cmType := EvenCommit + for _, lc := range lcs { + if lc == re.ReplaceAllString(c.Hash.String(), " ") { + cmType = LocalCommit + } + } commit := &Commit{ Hash: re.ReplaceAllString(c.Hash.String(), " "), Author: c.Author.Email, Message: re.ReplaceAllString(c.Message, " "), Time: c.Author.When.String(), - CommitType: LocalCommit, + CommitType: cmType, } entity.Commits = append(entity.Commits, commit) diff --git a/pkg/gui/commitsview.go b/pkg/gui/commitsview.go index 91cb795..6d1325c 100644 --- a/pkg/gui/commitsview.go +++ b/pkg/gui/commitsview.go @@ -20,8 +20,10 @@ func (gui *Gui) updateCommits(g *gocui.Gui, entity *git.RepoEntity) error { totalcommits := len(entity.Commits) for i, c := range entity.Commits { var body string - if c.CommitType == git.LocalCommit { + if c.CommitType == git.EvenCommit { body = cyan.Sprint(c.Hash[:hashLength]) + " " + c.Message + } else if c.CommitType == git.LocalCommit { + body = blue.Sprint(c.Hash[:hashLength]) + " " + c.Message } else { body = yellow.Sprint(c.Hash[:hashLength]) + " " + c.Message } |
