summaryrefslogtreecommitdiffstats
path: root/pkg/git/commit_list_builder.go
diff options
context:
space:
mode:
authorJesse Duffield Duffield <jesseduffieldduffield@Jesses-MacBook-Pro-3.local>2019-02-24 13:51:52 +1100
committerJesse Duffield Duffield <jesseduffieldduffield@Jesses-MacBook-Pro-3.local>2019-02-24 13:51:52 +1100
commita8858cbd12bd2ef5766f2436a7d43e4ff1c4ca9f (patch)
tree19febb0f502e2ff050ddde80de166e8354218ced /pkg/git/commit_list_builder.go
parent1a19b1412d3da03992403cf62fddf06031de2927 (diff)
support cherry picking commits
Diffstat (limited to 'pkg/git/commit_list_builder.go')
-rw-r--r--pkg/git/commit_list_builder.go46
1 files changed, 35 insertions, 11 deletions
diff --git a/pkg/git/commit_list_builder.go b/pkg/git/commit_list_builder.go
index ffb97c53b..3de255d02 100644
--- a/pkg/git/commit_list_builder.go
+++ b/pkg/git/commit_list_builder.go
@@ -23,19 +23,21 @@ import (
// CommitListBuilder returns a list of Branch objects for the current repo
type CommitListBuilder struct {
- Log *logrus.Entry
- GitCommand *commands.GitCommand
- OSCommand *commands.OSCommand
- Tr *i18n.Localizer
+ Log *logrus.Entry
+ GitCommand *commands.GitCommand
+ OSCommand *commands.OSCommand
+ Tr *i18n.Localizer
+ CherryPickedShas []string
}
// NewCommitListBuilder builds a new commit list builder
-func NewCommitListBuilder(log *logrus.Entry, gitCommand *commands.GitCommand, osCommand *commands.OSCommand, tr *i18n.Localizer) (*CommitListBuilder, error) {
+func NewCommitListBuilder(log *logrus.Entry, gitCommand *commands.GitCommand, osCommand *commands.OSCommand, tr *i18n.Localizer, cherryPickedShas []string) (*CommitListBuilder, error) {
return &CommitListBuilder{
- Log: log,
- GitCommand: gitCommand,
- OSCommand: osCommand,
- Tr: tr,
+ Log: log,
+ GitCommand: gitCommand,
+ OSCommand: osCommand,
+ Tr: tr,
+ CherryPickedShas: cherryPickedShas,
}, nil
}
@@ -80,7 +82,18 @@ func (c *CommitListBuilder) GetCommits() ([]*commands.Commit, error) {
youAreHere := blue.Sprintf("<-- %s ---", c.Tr.SLocalize("YouAreHere"))
currentCommit.Name = fmt.Sprintf("%s %s", youAreHere, currentCommit.Name)
}
- return c.setCommitMergedStatuses(commits)
+
+ commits, err = c.setCommitMergedStatuses(commits)
+ if err != nil {
+ return nil, err
+ }
+
+ commits, err = c.setCommitCherryPickStatuses(commits)
+ if err != nil {
+ return nil, err
+ }
+
+ return commits, nil
}
// git-rebase-todo example:
@@ -106,7 +119,7 @@ func (c *CommitListBuilder) getRebasingCommits() ([]*commands.Commit, error) {
commits := []*commands.Commit{}
lines := strings.Split(string(bytesContent), "\n")
for _, line := range lines {
- if line == "" {
+ if line == "" || line == "noop" {
return commits, nil
}
splitLine := strings.Split(line, " ")
@@ -144,6 +157,17 @@ func (c *CommitListBuilder) setCommitMergedStatuses(commits []*commands.Commit)
return commits, nil
}
+func (c *CommitListBuilder) setCommitCherryPickStatuses(commits []*commands.Commit) ([]*commands.Commit, error) {
+ for _, commit := range commits {
+ for _, sha := range c.CherryPickedShas {
+ if commit.Sha == sha {
+ commit.Copied = true
+ }
+ }
+ }
+ return commits, nil
+}
+
func (c *CommitListBuilder) getMergeBase() (string, error) {
currentBranch, err := c.GitCommand.CurrentBranchName()
if err != nil {