mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-15 22:26:40 +02:00
allow updating submodule url
This commit is contained in:
parent
d4ab607d0d
commit
71d4c552af
@ -94,7 +94,7 @@ func (c *GitCommand) SubmoduleDelete(submodule *models.SubmoduleConfig) error {
|
||||
return os.RemoveAll(filepath.Join(c.DotGitDir, "modules", submodule.Path))
|
||||
}
|
||||
|
||||
func (c *GitCommand) AddSubmodule(name string, path string, url string) error {
|
||||
func (c *GitCommand) SubmoduleAdd(name string, path string, url string) error {
|
||||
return c.OSCommand.RunCommand(
|
||||
"git submodule add --force --name %s -- %s %s ",
|
||||
c.OSCommand.Quote(name),
|
||||
@ -102,3 +102,7 @@ func (c *GitCommand) AddSubmodule(name string, path string, url string) error {
|
||||
c.OSCommand.Quote(path),
|
||||
)
|
||||
}
|
||||
|
||||
func (c *GitCommand) SubmoduleUpdateUrl(path string, newUrl string) error {
|
||||
return c.OSCommand.RunCommand("git submodule set-url -- %s %s", path, newUrl)
|
||||
}
|
||||
|
@ -1608,6 +1608,13 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
||||
Handler: gui.wrappedHandler(gui.handleAddSubmodule),
|
||||
Description: gui.Tr.SLocalize("addSubmodule"),
|
||||
},
|
||||
{
|
||||
ViewName: "files",
|
||||
Contexts: []string{SUBMODULES_CONTEXT_KEY},
|
||||
Key: gui.getKey("universal.edit"),
|
||||
Handler: gui.wrappedHandler(gui.handleEditSubmoduleUrl),
|
||||
Description: gui.Tr.SLocalize("editSubmoduleUrl"),
|
||||
},
|
||||
}
|
||||
|
||||
for _, viewName := range []string{"status", "branches", "files", "commits", "commitFiles", "stash", "menu"} {
|
||||
|
@ -130,24 +130,32 @@ func (gui *Gui) handleAddSubmodule() error {
|
||||
return gui.prompt(gui.Tr.SLocalize("newSubmoduleName"), nameSuggestion, func(submoduleName string) error {
|
||||
return gui.prompt(gui.Tr.SLocalize("newSubmodulePath"), submoduleName, func(submodulePath string) error {
|
||||
return gui.WithWaitingStatus(gui.Tr.SLocalize("addingSubmoduleStatus"), func() error {
|
||||
err := gui.GitCommand.AddSubmodule(submoduleName, submodulePath, submoduleUrl)
|
||||
err := gui.GitCommand.SubmoduleAdd(submoduleName, submodulePath, submoduleUrl)
|
||||
gui.handleCredentialsPopup(err)
|
||||
|
||||
return gui.refreshSidePanels(refreshOptions{scope: []int{SUBMODULES}})
|
||||
})
|
||||
|
||||
// go func() {
|
||||
// err := gui.GitCommand.AddSubmodule(submoduleName, submodulePath, submoduleUrl)
|
||||
// gui.handleCredentialsPopup(err)
|
||||
|
||||
// _ = gui.refreshSidePanels(refreshOptions{scope: []int{SUBMODULES}})
|
||||
// }()
|
||||
return nil
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
func (gui *Gui) handleEditSubmoduleUrl() error {
|
||||
submodule := gui.getSelectedSubmodule()
|
||||
if submodule == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return gui.prompt(gui.Tr.SLocalizef("updateSubmoduleUrl", submodule.Name), submodule.Url, func(newUrl string) error {
|
||||
return gui.WithWaitingStatus(gui.Tr.SLocalize("updatingSubmoduleUrlStatus"), func() error {
|
||||
err := gui.GitCommand.SubmoduleUpdateUrl(submodule.Name, newUrl)
|
||||
gui.handleCredentialsPopup(err)
|
||||
|
||||
return gui.refreshSidePanels(refreshOptions{scope: []int{SUBMODULES}})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// func (gui *Gui) handleEditsubmodule(g *gocui.Gui, v *gocui.View) error {
|
||||
// submodule := gui.getSelectedSubmodule()
|
||||
// if submodule == nil {
|
||||
|
@ -1230,6 +1230,15 @@ func addEnglish(i18nObject *i18n.Bundle) error {
|
||||
}, &i18n.Message{
|
||||
ID: "addingSubmoduleStatus",
|
||||
Other: "adding submodule",
|
||||
}, &i18n.Message{
|
||||
ID: "updateSubmoduleUrl",
|
||||
Other: "update URL for submodule '%s'",
|
||||
}, &i18n.Message{
|
||||
ID: "updatingSubmoduleUrlStatus",
|
||||
Other: "updating URL",
|
||||
}, &i18n.Message{
|
||||
ID: "editSubmoduleUrl",
|
||||
Other: "update submodule URL",
|
||||
},
|
||||
)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user