summaryrefslogtreecommitdiffstats
path: root/pkg/commands/git_commands/commit_file_loader.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2023-05-19 20:18:02 +1000
committerJesse Duffield <jessedduffield@gmail.com>2023-05-20 20:54:24 +1000
commit25f8b0337e1e023fd9575ecd46467810c9f49824 (patch)
treeda4937d66b110d6f69621c79d98c3d9ce9384b41 /pkg/commands/git_commands/commit_file_loader.go
parent63ddc52a6b0b69b656b106ee5ae74dd736ac6317 (diff)
Add convenience builder for git commands
Diffstat (limited to 'pkg/commands/git_commands/commit_file_loader.go')
-rw-r--r--pkg/commands/git_commands/commit_file_loader.go19
1 files changed, 12 insertions, 7 deletions
diff --git a/pkg/commands/git_commands/commit_file_loader.go b/pkg/commands/git_commands/commit_file_loader.go
index 0b606ae86..53ca046ba 100644
--- a/pkg/commands/git_commands/commit_file_loader.go
+++ b/pkg/commands/git_commands/commit_file_loader.go
@@ -1,7 +1,6 @@
package git_commands
import (
- "fmt"
"strings"
"github.com/jesseduffield/generics/slices"
@@ -25,12 +24,18 @@ func NewCommitFileLoader(common *common.Common, cmd oscommands.ICmdObjBuilder) *
// GetFilesInDiff get the specified commit files
func (self *CommitFileLoader) GetFilesInDiff(from string, to string, reverse bool) ([]*models.CommitFile, error) {
- reverseFlag := ""
- if reverse {
- reverseFlag = " -R "
- }
-
- filenames, err := self.cmd.New(fmt.Sprintf("git diff --submodule --no-ext-diff --name-status -z --no-renames %s %s %s", reverseFlag, from, to)).DontLog().RunWithOutput()
+ cmdStr := NewGitCmd("diff").
+ Arg("--submodule").
+ Arg("--no-ext-diff").
+ Arg("--name-status").
+ Arg("-z").
+ Arg("--no-renames").
+ ArgIf(reverse, "-R").
+ Arg(from).
+ Arg(to).
+ ToString()
+
+ filenames, err := self.cmd.New(cmdStr).DontLog().RunWithOutput()
if err != nil {
return nil, err
}