summaryrefslogtreecommitdiffstats
path: root/pkg/commands
diff options
context:
space:
mode:
authorskanehira <sho19921005@gmail.com>2019-03-23 22:46:08 +0900
committerJesse Duffield <jessedduffield@gmail.com>2019-04-06 13:02:20 +1100
commitc350cdba4337fa8961e5fbe16e70d73fae7ccc20 (patch)
treed0445a56f0d964f6d50f200042851ec8b3c02e7f /pkg/commands
parent1a933eaa731e910cc22e361b93cba8fd5603016f (diff)
add feature of display diff between specific commits #397
Diffstat (limited to 'pkg/commands')
-rw-r--r--pkg/commands/commit.go10
-rw-r--r--pkg/commands/git.go6
2 files changed, 15 insertions, 1 deletions
diff --git a/pkg/commands/commit.go b/pkg/commands/commit.go
index 4253a5495..8f23ca001 100644
--- a/pkg/commands/commit.go
+++ b/pkg/commands/commit.go
@@ -13,6 +13,7 @@ type Commit struct {
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
+ Selected bool
}
// GetDisplayStrings is a function.
@@ -52,5 +53,12 @@ func (c *Commit) GetDisplayStrings(isFocused bool) []string {
actionString = cyan.Sprint(utils.WithPadding(c.Action, 7)) + " "
}
- return []string{shaColor.Sprint(c.Sha), actionString + white.Sprint(c.Name)}
+ name := ""
+ if c.Selected {
+ name = color.New(color.FgMagenta).Sprint(c.Name)
+ } else {
+ name = white.Sprint(c.Name)
+ }
+
+ return []string{shaColor.Sprint(c.Sha), actionString + name}
}
diff --git a/pkg/commands/git.go b/pkg/commands/git.go
index 1b798990c..afd18dee7 100644
--- a/pkg/commands/git.go
+++ b/pkg/commands/git.go
@@ -910,3 +910,9 @@ func (c *GitCommand) ResetHardHead() error {
func (c *GitCommand) ResetSoftHead() error {
return c.OSCommand.RunCommand("git reset --soft HEAD")
}
+
+// DiffCommits show diff between commits
+func (c *GitCommand) DiffCommits(sha1, sha2 string) (string, error) {
+ cmd := fmt.Sprintf("git diff --color %s %s", sha1, sha2)
+ return c.OSCommand.RunCommandWithOutput(cmd)
+}