diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go index 1a35210da..9fa3703a9 100644 --- a/pkg/gui/files_panel.go +++ b/pkg/gui/files_panel.go @@ -242,16 +242,29 @@ func (gui *Gui) handleStageAll(g *gocui.Gui, v *gocui.View) error { } func (gui *Gui) handleIgnoreFile(g *gocui.Gui, v *gocui.View) error { - file, err := gui.getSelectedFile(g) + file, err := gui.getSelectedFile(gui.g) if err != nil { - return gui.createErrorPanel(g, err.Error()) + return gui.createErrorPanel(gui.g, err.Error()) } + if file.Tracked { - return gui.createErrorPanel(g, gui.Tr.SLocalize("CantIgnoreTrackFiles")) + return gui.createConfirmationPanel(gui.g, gui.g.CurrentView(), true, gui.Tr.SLocalize("IgnoreTracked"), gui.Tr.SLocalize("IgnoreTrackedPrompt"), + // On confirmation + func(_ *gocui.Gui, _ *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 { + return err + } + return gui.refreshFiles() + }, nil) } + if err := gui.GitCommand.Ignore(file.Name); err != nil { - return gui.createErrorPanel(g, err.Error()) + return gui.createErrorPanel(gui.g, err.Error()) } + return gui.refreshFiles() } diff --git a/pkg/i18n/dutch.go b/pkg/i18n/dutch.go index 323d7fafa..fbde75d69 100644 --- a/pkg/i18n/dutch.go +++ b/pkg/i18n/dutch.go @@ -136,9 +136,6 @@ func addDutch(i18nObject *i18n.Bundle) error { }, &i18n.Message{ ID: "CannotGitAdd", Other: "Kan commando niet uitvoeren git add --path untracked files", - }, &i18n.Message{ - ID: "CantIgnoreTrackFiles", - Other: "Kan gevolgde bestanden niet negeren", }, &i18n.Message{ ID: "NoStagedFilesToCommit", Other: "Er zijn geen staged bestanden om te commiten", @@ -760,6 +757,12 @@ func addDutch(i18nObject *i18n.Bundle) error { }, &i18n.Message{ ID: "ReturnToRemotesList", Other: `return to remotes list`, + }, &i18n.Message{ + ID: "IgnoreTracked", + Other: "Ignore tracked file", + }, &i18n.Message{ + ID: "IgnoreTrackedPrompt", + Other: "Are you sure you want to ignore a tracked file?", }, ) } diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index 5f63f18b4..2d7c40624 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -162,9 +162,6 @@ func addEnglish(i18nObject *i18n.Bundle) error { }, &i18n.Message{ ID: "CannotGitAdd", Other: "Cannot git add --patch untracked files", - }, &i18n.Message{ - ID: "CantIgnoreTrackFiles", - Other: "Cannot ignore tracked files", }, &i18n.Message{ ID: "NoStagedFilesToCommit", Other: "There are no staged files to commit", @@ -939,6 +936,12 @@ func addEnglish(i18nObject *i18n.Bundle) error { }, &i18n.Message{ ID: "NewBranchNamePrompt", Other: "new {{.branchType}} name:", + }, &i18n.Message{ + ID: "IgnoreTracked", + Other: "Ignore tracked file", + }, &i18n.Message{ + ID: "IgnoreTrackedPrompt", + Other: "Are you sure you want to ignore a tracked file?", }, ) } diff --git a/pkg/i18n/polish.go b/pkg/i18n/polish.go index 8afe27036..5e9db605a 100644 --- a/pkg/i18n/polish.go +++ b/pkg/i18n/polish.go @@ -128,9 +128,6 @@ func addPolish(i18nObject *i18n.Bundle) error { }, &i18n.Message{ ID: "CannotGitAdd", Other: "Nie można git add --patch nieśledzonych plików", - }, &i18n.Message{ - ID: "CantIgnoreTrackFiles", - Other: "Nie można zignorować nieśledzonych plików", }, &i18n.Message{ ID: "NoStagedFilesToCommit", Other: "Brak zatwierdzonych plików do commita", @@ -743,6 +740,12 @@ func addPolish(i18nObject *i18n.Bundle) error { }, &i18n.Message{ ID: "ReturnToRemotesList", Other: `return to remotes list`, + }, &i18n.Message{ + ID: "IgnoreTracked", + Other: "Ignore tracked file", + }, &i18n.Message{ + ID: "IgnoreTrackedPrompt", + Other: "Are you sure you want to ignore a tracked file?", }, ) }