Skip to content

Commit

Permalink
Pass entire submodule to UpdateUrl instead of name and path separately
Browse files Browse the repository at this point in the history
This will make the next commit slightly simpler.
  • Loading branch information
stefanhaller committed Mar 7, 2024
1 parent ea87912 commit db4f129
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions pkg/commands/git_commands/submodule.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,10 @@ func (self *SubmoduleCommands) Add(name string, path string, url string) error {
return self.cmd.New(cmdArgs).Run()
}

func (self *SubmoduleCommands) UpdateUrl(name string, path string, newUrl string) error {
func (self *SubmoduleCommands) UpdateUrl(submodule *models.SubmoduleConfig, newUrl string) error {
setUrlCmdStr := NewGitCmd("config").
Arg(
"--file", ".gitmodules", "submodule."+name+".url", newUrl,
"--file", ".gitmodules", "submodule."+submodule.Name+".url", newUrl,
).
ToArgv()

Expand All @@ -170,7 +170,7 @@ func (self *SubmoduleCommands) UpdateUrl(name string, path string, newUrl string
return err
}

syncCmdStr := NewGitCmd("submodule").Arg("sync", "--", path).
syncCmdStr := NewGitCmd("submodule").Arg("sync", "--", submodule.Path).
ToArgv()

if err := self.cmd.New(syncCmdStr).Run(); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/gui/controllers/submodules_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func (self *SubmodulesController) editURL(submodule *models.SubmoduleConfig) err
HandleConfirm: func(newUrl string) error {
return self.c.WithWaitingStatus(self.c.Tr.UpdatingSubmoduleUrlStatus, func(gocui.Task) error {
self.c.LogAction(self.c.Tr.Actions.UpdateSubmoduleUrl)
err := self.c.Git().Submodule.UpdateUrl(submodule.Name, submodule.Path, newUrl)
err := self.c.Git().Submodule.UpdateUrl(submodule, newUrl)
if err != nil {
_ = self.c.Error(err)
}
Expand Down

0 comments on commit db4f129

Please sign in to comment.