summaryrefslogtreecommitdiffstats
path: root/pkg/commands
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2022-01-26 01:20:19 +1100
committerJesse Duffield <jessedduffield@gmail.com>2022-01-26 14:50:47 +1100
commitc8cc18920f0b5ab54a19b9f7bdcf83db3210576f (patch)
tree60623fbe5504469b9a4f4ca25a9a538b4eee52ce /pkg/commands
parentce3bcfe37cf0c68f501fb09d543e9e212b0eaa61 (diff)
improve merge conflict flow
Diffstat (limited to 'pkg/commands')
-rw-r--r--pkg/commands/git_commands/working_tree.go13
-rw-r--r--pkg/commands/git_commands/working_tree_test.go10
-rw-r--r--pkg/commands/loaders/files.go2
3 files changed, 22 insertions, 3 deletions
diff --git a/pkg/commands/git_commands/working_tree.go b/pkg/commands/git_commands/working_tree.go
index 4e97913fb..f594a639b 100644
--- a/pkg/commands/git_commands/working_tree.go
+++ b/pkg/commands/git_commands/working_tree.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
"path/filepath"
+ "strings"
"time"
"github.com/go-errors/errors"
@@ -40,8 +41,16 @@ func (self *WorkingTreeCommands) OpenMergeTool() error {
}
// StageFile stages a file
-func (self *WorkingTreeCommands) StageFile(fileName string) error {
- return self.cmd.New("git add -- " + self.cmd.Quote(fileName)).Run()
+func (self *WorkingTreeCommands) StageFile(path string) error {
+ return self.StageFiles([]string{path})
+}
+
+func (self *WorkingTreeCommands) StageFiles(paths []string) error {
+ quotedPaths := make([]string, len(paths))
+ for i, path := range paths {
+ quotedPaths[i] = self.cmd.Quote(path)
+ }
+ return self.cmd.New(fmt.Sprintf("git add -- %s", strings.Join(quotedPaths, " "))).Run()
}
// StageAll stages all files
diff --git a/pkg/commands/git_commands/working_tree_test.go b/pkg/commands/git_commands/working_tree_test.go
index 8b2c70714..e4e884ce4 100644
--- a/pkg/commands/git_commands/working_tree_test.go
+++ b/pkg/commands/git_commands/working_tree_test.go
@@ -23,6 +23,16 @@ func TestWorkingTreeStageFile(t *testing.T) {
runner.CheckForMissingCalls()
}
+func TestWorkingTreeStageFiles(t *testing.T) {
+ runner := oscommands.NewFakeRunner(t).
+ Expect(`git add -- "test.txt" "test2.txt"`, "", nil)
+
+ instance := buildWorkingTreeCommands(commonDeps{runner: runner})
+
+ assert.NoError(t, instance.StageFiles([]string{"test.txt", "test2.txt"}))
+ runner.CheckForMissingCalls()
+}
+
func TestWorkingTreeUnstageFile(t *testing.T) {
type scenario struct {
testName string
diff --git a/pkg/commands/loaders/files.go b/pkg/commands/loaders/files.go
index 1e056cb98..f5becdb92 100644
--- a/pkg/commands/loaders/files.go
+++ b/pkg/commands/loaders/files.go
@@ -59,8 +59,8 @@ func (self *FileLoader) GetStatusFiles(opts GetStatusFileOptions) []*models.File
unstagedChange := change[1:2]
untracked := utils.IncludesString([]string{"??", "A ", "AM"}, change)
hasNoStagedChanges := utils.IncludesString([]string{" ", "U", "?"}, stagedChange)
- hasMergeConflicts := utils.IncludesString([]string{"DD", "AA", "UU", "AU", "UA", "UD", "DU"}, change)
hasInlineMergeConflicts := utils.IncludesString([]string{"UU", "AA"}, change)
+ hasMergeConflicts := hasInlineMergeConflicts || utils.IncludesString([]string{"DD", "AU", "UA", "UD", "DU"}, change)
file := &models.File{
Name: status.Name,