diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2020-03-26 09:18:52 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2020-03-26 18:30:02 +1100 |
commit | 37acc17cf3dc7df94aef5ee5a2c62763ea655bf2 (patch) | |
tree | 9068aa4ea52e4eaac020ea2d468f4b3b8ce41cd1 /pkg/commands | |
parent | 569ec5919cc1801783082d326d279f153fc806c8 (diff) |
more lenient getting of short shas
Diffstat (limited to 'pkg/commands')
-rw-r--r-- | pkg/commands/commit.go | 7 | ||||
-rw-r--r-- | pkg/commands/commit_list_builder.go | 2 |
2 files changed, 8 insertions, 1 deletions
diff --git a/pkg/commands/commit.go b/pkg/commands/commit.go index 4d440d5e3..32daeaa23 100644 --- a/pkg/commands/commit.go +++ b/pkg/commands/commit.go @@ -13,3 +13,10 @@ type Commit struct { Author string Date string } + +func (c *Commit) ShortSha() string { + if len(c.Sha) < 8 { + return c.Sha + } + return c.Sha[:8] +} diff --git a/pkg/commands/commit_list_builder.go b/pkg/commands/commit_list_builder.go index a31657b34..cab1b714d 100644 --- a/pkg/commands/commit_list_builder.go +++ b/pkg/commands/commit_list_builder.go @@ -105,7 +105,7 @@ func (c *CommitListBuilder) GetCommits(limit bool) ([]*Commit, error) { // now we can split it up and turn it into commits for _, line := range utils.SplitLines(log) { commit := c.extractCommitFromLine(line) - _, unpushed := unpushedCommits[commit.Sha[:8]] + _, unpushed := unpushedCommits[commit.ShortSha()] commit.Status = map[bool]string{true: "unpushed", false: "pushed"}[unpushed] commits = append(commits, commit) } |