1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-12-02 09:21:40 +02:00

implement config option for disabling force pushing

This commit is contained in:
Francisco Miamoto 2020-08-29 23:23:08 -03:00 committed by Jesse Duffield
parent 86f296a898
commit 70eda031dc
4 changed files with 28 additions and 1 deletions

View File

@ -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"),

View File

@ -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",

View File

@ -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",

View File

@ -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",