diff options
author | Francisco Miamoto <fsmiamoto@gmail.com> | 2020-08-29 23:23:08 -0300 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2020-08-31 09:22:39 +1000 |
commit | 70eda031dcb4aa24422da54c6356fc60e22a037a (patch) | |
tree | bf680cd56f9664dbc539c15d3fdeed38cecdfdde /pkg/gui/files_panel.go | |
parent | 86f296a898d1df3b827618c2645c21fd9c60526d (diff) |
implement config option for disabling force pushing
Diffstat (limited to 'pkg/gui/files_panel.go')
-rw-r--r-- | pkg/gui/files_panel.go | 11 |
1 files changed, 10 insertions, 1 deletions
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"), |