diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go index 9861e0cd6..0a8e1fc28 100644 --- a/pkg/gui/files_panel.go +++ b/pkg/gui/files_panel.go @@ -517,6 +517,11 @@ func (gui *Gui) pushWithForceFlag(v *gocui.View, force bool, upstream string, ar branchName := gui.getCheckedOutBranch().Name err := gui.GitCommand.Push(branchName, force, upstream, args, gui.promptUserForCredential) if err != nil && !force && strings.Contains(err.Error(), "Updates were rejected") { + forcePushDisabled := gui.Config.GetUserConfig().Get("git.disableForcePushing").(bool) + if forcePushDisabled { + gui.createErrorPanel(gui.Tr.SLocalize("UpdatesRejectedAndForcePushDisabled")) + return + } gui.ask(askOpts{ title: gui.Tr.SLocalize("ForcePush"), prompt: gui.Tr.SLocalize("ForcePushPrompt"), @@ -524,7 +529,6 @@ func (gui *Gui) pushWithForceFlag(v *gocui.View, force bool, upstream string, ar return gui.pushWithForceFlag(v, true, upstream, args) }, }) - return } gui.handleCredentialsPopup(err) @@ -564,6 +568,11 @@ func (gui *Gui) pushFiles(g *gocui.Gui, v *gocui.View) error { return gui.pushWithForceFlag(v, false, "", "") } + forcePushDisabled := gui.Config.GetUserConfig().Get("git.disableForcePushing").(bool) + if forcePushDisabled { + return gui.createErrorPanel(gui.Tr.SLocalize("ForcePushDisabled")) + } + return gui.ask(askOpts{ title: gui.Tr.SLocalize("ForcePush"), prompt: gui.Tr.SLocalize("ForcePushPrompt"), diff --git a/pkg/i18n/dutch.go b/pkg/i18n/dutch.go index 28552f433..e9fe3d856 100644 --- a/pkg/i18n/dutch.go +++ b/pkg/i18n/dutch.go @@ -418,6 +418,12 @@ func addDutch(i18nObject *i18n.Bundle) error { }, &i18n.Message{ ID: "ForcePushPrompt", Other: "Jouw branch is afgeweken van de remote branch. Druk 'esc' om te annuleren, of 'enter' om geforceert te pushen.", + }, &i18n.Message{ + ID: "ForcePushDisabled", + Other: "Your branch has diverged from the remote branch and you've disabled force pushing", + }, &i18n.Message{ + ID: "UpdatesRejectedAndForcePushDisabled", + Other: "Updates were rejected and you have disabled force pushing", }, &i18n.Message{ ID: "checkForUpdate", Other: "check voor updates", diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index d3e170d2d..5368001d6 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -426,6 +426,12 @@ func addEnglish(i18nObject *i18n.Bundle) error { }, &i18n.Message{ ID: "ForcePushPrompt", Other: "Your branch has diverged from the remote branch. Press 'esc' to cancel, or 'enter' to force push.", + }, &i18n.Message{ + ID: "ForcePushDisabled", + Other: "Your branch has diverged from the remote branch and you've disabled force pushing", + }, &i18n.Message{ + ID: "UpdatesRejectedAndForcePushDisabled", + Other: "Updates were rejected and you have disabled force pushing", }, &i18n.Message{ ID: "checkForUpdate", Other: "check for update", diff --git a/pkg/i18n/polish.go b/pkg/i18n/polish.go index 17ec4b2f2..d5e272772 100644 --- a/pkg/i18n/polish.go +++ b/pkg/i18n/polish.go @@ -338,6 +338,12 @@ func addPolish(i18nObject *i18n.Bundle) error { }, &i18n.Message{ ID: "ForcePushPrompt", Other: "Twoja gałąź rozeszła się z gałęzią zdalną. Wciśnij 'esc' aby anulować lub 'enter' aby wymusić wypchnięcie.", + }, &i18n.Message{ + ID: "ForcePushDisabled", + Other: "Your branch has diverged from the remote branch and you've disabled force pushing", + }, &i18n.Message{ + ID: "UpdatesRejectedAndForcePushDisabled", + Other: "Updates were rejected and you have disabled force pushing", }, &i18n.Message{ ID: "checkForUpdate", Other: "sprawdź aktualizacje",