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))
|
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(
|
return c.OSCommand.RunCommand(
|
||||||
"git submodule add --force --name %s -- %s %s ",
|
"git submodule add --force --name %s -- %s %s ",
|
||||||
c.OSCommand.Quote(name),
|
c.OSCommand.Quote(name),
|
||||||
@ -102,3 +102,7 @@ func (c *GitCommand) AddSubmodule(name string, path string, url string) error {
|
|||||||
c.OSCommand.Quote(path),
|
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),
|
Handler: gui.wrappedHandler(gui.handleAddSubmodule),
|
||||||
Description: gui.Tr.SLocalize("addSubmodule"),
|
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"} {
|
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("newSubmoduleName"), nameSuggestion, func(submoduleName string) error {
|
||||||
return gui.prompt(gui.Tr.SLocalize("newSubmodulePath"), submoduleName, func(submodulePath string) error {
|
return gui.prompt(gui.Tr.SLocalize("newSubmodulePath"), submoduleName, func(submodulePath string) error {
|
||||||
return gui.WithWaitingStatus(gui.Tr.SLocalize("addingSubmoduleStatus"), func() 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)
|
gui.handleCredentialsPopup(err)
|
||||||
|
|
||||||
return gui.refreshSidePanels(refreshOptions{scope: []int{SUBMODULES}})
|
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 {
|
// func (gui *Gui) handleEditsubmodule(g *gocui.Gui, v *gocui.View) error {
|
||||||
// submodule := gui.getSelectedSubmodule()
|
// submodule := gui.getSelectedSubmodule()
|
||||||
// if submodule == nil {
|
// if submodule == nil {
|
||||||
|
@ -1230,6 +1230,15 @@ func addEnglish(i18nObject *i18n.Bundle) error {
|
|||||||
}, &i18n.Message{
|
}, &i18n.Message{
|
||||||
ID: "addingSubmoduleStatus",
|
ID: "addingSubmoduleStatus",
|
||||||
Other: "adding submodule",
|
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