From c350cdba4337fa8961e5fbe16e70d73fae7ccc20 Mon Sep 17 00:00:00 2001 From: skanehira Date: Sat, 23 Mar 2019 22:46:08 +0900 Subject: add feature of display diff between specific commits #397 --- pkg/commands/commit.go | 10 +++++++++- pkg/commands/git.go | 6 ++++++ 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'pkg/commands') 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) +} -- cgit v1.2.3