summaryrefslogtreecommitdiffstats
path: root/pkg/commands
diff options
context:
space:
mode:
authorskanehira <sho19921005@gmail.com>2019-03-09 23:42:10 +0900
committerJesse Duffield <jessedduffield@gmail.com>2019-03-16 10:20:27 +1100
commit06fe726ee79d3993d936ae3e064761273b657ae8 (patch)
tree1da4c337f9e506944f762c09ba930451c5c823b4 /pkg/commands
parent1b6e46973ebfdb6ba873fac6a2ce05bb1f8db8c1 (diff)
Add feature of display committed file list #383
Diffstat (limited to 'pkg/commands')
-rw-r--r--pkg/commands/commit_file.go13
-rw-r--r--pkg/commands/git.go12
2 files changed, 25 insertions, 0 deletions
diff --git a/pkg/commands/commit_file.go b/pkg/commands/commit_file.go
new file mode 100644
index 000000000..5910ccfec
--- /dev/null
+++ b/pkg/commands/commit_file.go
@@ -0,0 +1,13 @@
+package commands
+
+// CommitFile : A git commit file
+type CommitFile struct {
+ Sha string
+ Name string
+ DisplayString string
+}
+
+// GetDisplayStrings is a function.
+func (f *CommitFile) GetDisplayStrings() []string {
+ return []string{f.DisplayString}
+}
diff --git a/pkg/commands/git.go b/pkg/commands/git.go
index 43f78a28f..3e0bf2441 100644
--- a/pkg/commands/git.go
+++ b/pkg/commands/git.go
@@ -796,3 +796,15 @@ func (c *GitCommand) CherryPickCommits(commits []*Commit) error {
return c.OSCommand.RunPreparedCommand(cmd)
}
+
+// CommitFiles get the specified commit files
+func (c *GitCommand) CommitFiles(commitID string) (string, error) {
+ cmd := fmt.Sprintf("git show --pretty= --name-only %s", commitID)
+ return c.OSCommand.RunCommandWithOutput(cmd)
+}
+
+// ShowCommitFile get the diff of specified commit file
+func (c *GitCommand) ShowCommitFile(commitID, file string) (string, error) {
+ cmd := fmt.Sprintf("git show --color %s -- %s", commitID, file)
+ return c.OSCommand.RunCommandWithOutput(cmd)
+}