summaryrefslogtreecommitdiffstats
path: root/pkg/commands
diff options
context:
space:
mode:
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)
+}