summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Vriesman <glenn.vriesman@gmail.com>2020-02-03 16:59:46 +0100
committerJesse Duffield <jessedduffield@gmail.com>2020-02-06 23:19:29 +1100
commit0164abbd4a5c7206b5980d65aff1f9fa7fc3e188 (patch)
tree4a199a5467dd28cd53c794a0364b9076b8ad2ac0
parente92af63636d8e8c5ff830866632173e52ee86d63 (diff)
Added feature to ignore tracked files
Signed-off-by: Glenn Vriesman <glenn.vriesman@gmail.com>
-rw-r--r--pkg/gui/files_panel.go21
-rw-r--r--pkg/i18n/dutch.go9
-rw-r--r--pkg/i18n/english.go9
-rw-r--r--pkg/i18n/polish.go9
4 files changed, 35 insertions, 13 deletions
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
@@ -137,9 +137,6 @@ func addDutch(i18nObject *i18n.Bundle) error {
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",
}, &i18n.Message{
@@ -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
@@ -163,9 +163,6 @@ func addEnglish(i18nObject *i18n.Bundle) error {
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",
}, &i18n.Message{
@@ -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
@@ -129,9 +129,6 @@ func addPolish(i18nObject *i18n.Bundle) error {
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",
}, &i18n.Message{
@@ -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?",
},
)
}