summaryrefslogtreecommitdiffstats
path: root/pkg/commands
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/commands
parent1a19b1412d3da03992403cf62fddf06031de2927 (diff)
support cherry picking commits
Diffstat (limited to 'pkg/commands')
-rw-r--r--pkg/commands/commit.go12
-rw-r--r--pkg/commands/git.go15
2 files changed, 26 insertions, 1 deletions
diff --git a/pkg/commands/commit.go b/pkg/commands/commit.go
index 1df6afbd0..4253a5495 100644
--- a/pkg/commands/commit.go
+++ b/pkg/commands/commit.go
@@ -12,6 +12,7 @@ type Commit struct {
Status string // one of "unpushed", "pushed", "merged", or "rebasing"
DisplayString string
Action string // one of "", "pick", "edit", "squash", "reword", "drop", "fixup"
+ Copied bool // to know if this commit is ready to be cherry-picked somewhere
}
// GetDisplayStrings is a function.
@@ -19,9 +20,14 @@ func (c *Commit) GetDisplayStrings(isFocused bool) []string {
red := color.New(color.FgRed)
yellow := color.New(color.FgYellow)
green := color.New(color.FgGreen)
- white := color.New(color.FgWhite)
blue := color.New(color.FgBlue)
cyan := color.New(color.FgCyan)
+ white := color.New(color.FgWhite)
+
+ // for some reason, setting the background to blue pads out the other commits
+ // horizontally. For the sake of accessibility I'm considering this a feature,
+ // not a bug
+ copied := color.New(color.FgCyan, color.BgBlue)
var shaColor *color.Color
switch c.Status {
@@ -37,6 +43,10 @@ func (c *Commit) GetDisplayStrings(isFocused bool) []string {
shaColor = white
}
+ if c.Copied {
+ shaColor = copied
+ }
+
actionString := ""
if c.Action != "" {
actionString = cyan.Sprint(utils.WithPadding(c.Action, 7)) + " "
diff --git a/pkg/commands/git.go b/pkg/commands/git.go
index 7b2c2f2fa..7127a427e 100644
--- a/pkg/commands/git.go
+++ b/pkg/commands/git.go
@@ -745,3 +745,18 @@ func (c *GitCommand) MoveTodoDown(index int) error {
func (c *GitCommand) Revert(sha string) error {
return c.OSCommand.RunCommand(fmt.Sprintf("git revert %s", sha))
}
+
+// CherryPickShas begins an interactive rebase with the given shas being cherry picked onto HEAD
+func (c *GitCommand) CherryPickShas(shas []string) error {
+ todo := ""
+ for _, sha := range shas {
+ todo = "pick " + sha + "\n" + todo
+ }
+
+ cmd, err := c.PrepareInteractiveRebaseCommand("HEAD", todo, false)
+ if err != nil {
+ return err
+ }
+
+ return c.OSCommand.RunPreparedCommand(cmd)
+}