summaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2023-05-23 19:58:09 +1000
committerJesse Duffield <jessedduffield@gmail.com>2023-05-23 20:23:08 +1000
commitfb0931e1a1d21fb07cf924cdfea7213810b10d9c (patch)
tree5dcd202fb89717b88002b4092fca5fe296f31069 /pkg
parent63dc07fdedec58ae5836a601d9c8839d0481eda6 (diff)
Fix discard logic
Missed a spot a couple PR's ago. We had an integration test which caught this but which was skipped due to index.lock file issues. The test was also broken for other reasons due to it not having been running for a while, so I've fixed that up too.
Diffstat (limited to 'pkg')
-rw-r--r--pkg/commands/git_commands/working_tree.go2
-rw-r--r--pkg/integration/tests/file/discard_changes.go11
2 files changed, 8 insertions, 5 deletions
diff --git a/pkg/commands/git_commands/working_tree.go b/pkg/commands/git_commands/working_tree.go
index 6269ce21a..9a167de36 100644
--- a/pkg/commands/git_commands/working_tree.go
+++ b/pkg/commands/git_commands/working_tree.go
@@ -149,7 +149,7 @@ func (self *WorkingTreeCommands) DiscardAllFileChanges(file *models.File) error
if file.ShortStatus == "DU" {
return self.cmd.New(
- NewGitCmd("rm").Arg("rm", "--", file.Name).ToArgv(),
+ NewGitCmd("rm").Arg("--", file.Name).ToArgv(),
).Run()
}
diff --git a/pkg/integration/tests/file/discard_changes.go b/pkg/integration/tests/file/discard_changes.go
index dcc63bd59..b23b9888e 100644
--- a/pkg/integration/tests/file/discard_changes.go
+++ b/pkg/integration/tests/file/discard_changes.go
@@ -99,9 +99,13 @@ var DiscardChanges = NewIntegrationTest(NewIntegrationTestArgs{
{status: "DU", label: "deleted-us.txt", menuTitle: "deleted-us.txt"},
})
- t.Common().ContinueOnConflictsResolved()
+ t.ExpectPopup().Confirmation().
+ Title(Equals("continue")).
+ Content(Contains("all merge conflicts resolved. Continue?")).
+ Cancel()
discardOneByOne([]statusFile{
+ {status: "AM", label: "added-changed.txt", menuTitle: "added-changed.txt"},
{status: "MD", label: "change-delete.txt", menuTitle: "change-delete.txt"},
{status: "D ", label: "delete-change.txt", menuTitle: "delete-change.txt"},
{status: "D ", label: "deleted-staged.txt", menuTitle: "deleted-staged.txt"},
@@ -109,11 +113,10 @@ var DiscardChanges = NewIntegrationTest(NewIntegrationTestArgs{
{status: "MM", label: "double-modded.txt", menuTitle: "double-modded.txt"},
{status: "M ", label: "modded-staged.txt", menuTitle: "modded-staged.txt"},
{status: " M", label: "modded.txt", menuTitle: "modded.txt"},
- // the menu title only includes the new file
- {status: "R ", label: "renamed.txt → renamed2.txt", menuTitle: "renamed2.txt"},
- {status: "AM", label: "added-changed.txt", menuTitle: "added-changed.txt"},
{status: "A ", label: "new-staged.txt", menuTitle: "new-staged.txt"},
{status: "??", label: "new.txt", menuTitle: "new.txt"},
+ // the menu title only includes the new file
+ {status: "R ", label: "renamed.txt → renamed2.txt", menuTitle: "renamed2.txt"},
})
t.Views().Files().IsEmpty()