From 06fe726ee79d3993d936ae3e064761273b657ae8 Mon Sep 17 00:00:00 2001 From: skanehira Date: Sat, 9 Mar 2019 23:42:10 +0900 Subject: Add feature of display committed file list #383 --- pkg/commands/commit_file.go | 13 +++++++++++++ pkg/commands/git.go | 12 ++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 pkg/commands/commit_file.go (limited to 'pkg/commands') 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) +} -- cgit v1.2.3