From 9f5397a2d46a6a444e8d157c91fee5909006c63d Mon Sep 17 00:00:00 2001 From: Glenn Vriesman Date: Tue, 4 Feb 2020 12:50:13 +0100 Subject: [PATCH] Moved function to git.go Signed-off-by: Glenn Vriesman --- pkg/commands/git.go | 5 +++++ pkg/gui/files_panel.go | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/commands/git.go b/pkg/commands/git.go index adf304acd..ca0c83501 100644 --- a/pkg/commands/git.go +++ b/pkg/commands/git.go @@ -940,6 +940,11 @@ func (c *GitCommand) DiscardAnyUnstagedFileChanges() error { return c.OSCommand.RunCommand("git checkout -- .") } +// RemoveTrackedFiles will delete the given file(s) even if they are currently tracked +func (c *GitCommand) RemoveTrackedFiles(name string) error { + return c.OSCommand.RunCommand("git rm -r --cached %s", name) +} + // RemoveUntrackedFiles runs `git clean -fd` func (c *GitCommand) RemoveUntrackedFiles() error { return c.OSCommand.RunCommand("git clean -fd") diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go index 9fa3703a9..d7a5466cb 100644 --- a/pkg/gui/files_panel.go +++ b/pkg/gui/files_panel.go @@ -254,7 +254,7 @@ func (gui *Gui) handleIgnoreFile(g *gocui.Gui, v *gocui.View) error { if err := gui.GitCommand.Ignore(file.Name); err != nil { return err } - if err := gui.GitCommand.OSCommand.RunCommand("git rm -r --cached %s", file.Name); err != nil { + if err := gui.GitCommand.RemoveTrackedFiles(file.Name); err != nil { return err } return gui.refreshFiles()