From 7428a0a984d371e5442dd03ac58669b282fae38c Mon Sep 17 00:00:00 2001 From: Robin Gagnon Date: Fri, 20 Jan 2023 08:44:17 -0500 Subject: [PATCH] feat(status): Remove untracked file on discard (#66) --- cli/status.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cli/status.go b/cli/status.go index b82060d..8a3ca59 100644 --- a/cli/status.go +++ b/cli/status.go @@ -108,7 +108,7 @@ func (s *status) defineKeybindings() error { Key: '!', Display: "!", Desc: "discard changes", - Handler: s.checkoutEntry, + Handler: s.discardEntry, }, &prompt.KeyBinding{ Key: 'q', @@ -192,12 +192,14 @@ func (s *status) resetAllEntries(item interface{}) error { return s.runCommandWithArgs(args) } -func (s *status) checkoutEntry(item interface{}) error { +func (s *status) discardEntry(item interface{}) error { entry := item.(*git.StatusEntry) + var args []string if entry.EntryType == git.StatusEntryTypeUntracked { - return nil // you can't checkout untracked items + args = []string{"clean", "--force", entry.String()} + } else { + args = []string{"checkout", "--", entry.String()} } - args := []string{"checkout", "--", entry.String()} return s.runCommandWithArgs(args) }