mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-01-04 03:48:07 +02:00
allow updating submodule
This commit is contained in:
parent
da3e00823f
commit
86dd9d87dd
@ -166,6 +166,7 @@ Default path for the config file:
|
||||
pickBothHunks: 'b'
|
||||
submodules:
|
||||
init: 'i'
|
||||
update: 'u'
|
||||
```
|
||||
|
||||
## Platform Defaults
|
||||
|
@ -101,7 +101,8 @@ func (c *GitCommand) SubmoduleDelete(submodule *models.SubmoduleConfig) error {
|
||||
}
|
||||
|
||||
if err := c.OSCommand.RunCommand("git rm --force -r %s", submodule.Path); err != nil {
|
||||
return err
|
||||
// if the directory isn't there then that's fine
|
||||
c.Log.Error(err)
|
||||
}
|
||||
|
||||
return os.RemoveAll(filepath.Join(c.DotGitDir, "modules", submodule.Path))
|
||||
@ -128,3 +129,7 @@ func (c *GitCommand) SubmoduleUpdateUrl(name string, path string, newUrl string)
|
||||
func (c *GitCommand) SubmoduleInit(path string) error {
|
||||
return c.OSCommand.RunCommand("git submodule init %s", path)
|
||||
}
|
||||
|
||||
func (c *GitCommand) SubmoduleUpdate(path string) error {
|
||||
return c.OSCommand.RunCommand("git submodule update --init %s", path)
|
||||
}
|
||||
|
@ -395,6 +395,7 @@ keybinding:
|
||||
pickBothHunks: 'b'
|
||||
submodules:
|
||||
init: 'i'
|
||||
update: 'u'
|
||||
`)
|
||||
}
|
||||
|
||||
|
@ -1587,19 +1587,18 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
||||
Description: gui.Tr.SLocalize("enterSubmodule"),
|
||||
},
|
||||
{
|
||||
ViewName: "files",
|
||||
Contexts: []string{SUBMODULES_CONTEXT_KEY},
|
||||
Key: gui.getKey("universal.remove"),
|
||||
|
||||
Handler: gui.forSubmodule(gui.handleRemoveSubmodule),
|
||||
Description: gui.Tr.SLocalize("removeSubmodule"),
|
||||
ViewName: "files",
|
||||
Contexts: []string{SUBMODULES_CONTEXT_KEY},
|
||||
Key: gui.getKey("universal.remove"),
|
||||
Handler: gui.forSubmodule(gui.handleResetRemoveSubmodule),
|
||||
Description: gui.Tr.SLocalize("viewResetAndRemoveOptions"),
|
||||
},
|
||||
{
|
||||
ViewName: "files",
|
||||
Contexts: []string{SUBMODULES_CONTEXT_KEY},
|
||||
Key: gui.getKey("u"),
|
||||
Handler: gui.forSubmodule(gui.handleResetSubmodule),
|
||||
Description: gui.Tr.SLocalize("submoduleStashAndReset"),
|
||||
Key: gui.getKey("submodules.update"),
|
||||
Handler: gui.forSubmodule(gui.handleUpdateSubmodule),
|
||||
Description: gui.Tr.SLocalize("submoduleUpdate"),
|
||||
},
|
||||
{
|
||||
ViewName: "files",
|
||||
|
@ -77,7 +77,7 @@ func (gui *Gui) enterSubmodule(submodule *models.SubmoduleConfig) error {
|
||||
return gui.dispatchSwitchToRepo(submodule.Path)
|
||||
}
|
||||
|
||||
func (gui *Gui) handleRemoveSubmodule(submodule *models.SubmoduleConfig) error {
|
||||
func (gui *Gui) removeSubmodule(submodule *models.SubmoduleConfig) error {
|
||||
return gui.ask(askOpts{
|
||||
title: gui.Tr.SLocalize("RemoveSubmodule"),
|
||||
prompt: gui.Tr.SLocalizef("RemoveSubmodulePrompt", submodule.Name),
|
||||
@ -174,3 +174,31 @@ func (gui *Gui) forSubmodule(callback func(*models.SubmoduleConfig) error) func(
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
func (gui *Gui) handleResetRemoveSubmodule(submodule *models.SubmoduleConfig) error {
|
||||
menuItems := []*menuItem{
|
||||
{
|
||||
displayString: gui.Tr.SLocalize("submoduleStashAndReset"),
|
||||
onPress: func() error {
|
||||
return gui.resetSubmodule(submodule)
|
||||
},
|
||||
},
|
||||
{
|
||||
displayString: gui.Tr.SLocalize("removeSubmodule"),
|
||||
onPress: func() error {
|
||||
return gui.removeSubmodule(submodule)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
return gui.createMenu(submodule.Name, menuItems, createMenuOptions{showCancel: true})
|
||||
}
|
||||
|
||||
func (gui *Gui) handleUpdateSubmodule(submodule *models.SubmoduleConfig) error {
|
||||
return gui.WithWaitingStatus(gui.Tr.SLocalize("updatingSubmoduleStatus"), func() error {
|
||||
err := gui.GitCommand.SubmoduleUpdate(submodule.Path)
|
||||
gui.handleCredentialsPopup(err)
|
||||
|
||||
return gui.refreshSidePanels(refreshOptions{scope: []int{SUBMODULES}})
|
||||
})
|
||||
}
|
||||
|
@ -1245,6 +1245,15 @@ func addEnglish(i18nObject *i18n.Bundle) error {
|
||||
}, &i18n.Message{
|
||||
ID: "initSubmodule",
|
||||
Other: "initialize submodule",
|
||||
}, &i18n.Message{
|
||||
ID: "viewResetAndRemoveOptions",
|
||||
Other: "view reset and remove submodule options",
|
||||
}, &i18n.Message{
|
||||
ID: "submoduleUpdate",
|
||||
Other: "update submodule",
|
||||
}, &i18n.Message{
|
||||
ID: "updatingSubmoduleStatus",
|
||||
Other: "updating submodule",
|
||||
},
|
||||
)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user