diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2020-09-30 21:12:03 +1000 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2020-10-02 08:09:42 +1000 |
commit | d4ab607d0dd94f73eb1dcd4ba9842eb86b6aa0f4 (patch) | |
tree | 4cb72d33183f60fc8a943dd35d7299ce07d44cee /pkg/commands/submodules.go | |
parent | ea307c8d94623bd0279297db2cf3990492998ab4 (diff) |
allow adding a submodule
Diffstat (limited to 'pkg/commands/submodules.go')
-rw-r--r-- | pkg/commands/submodules.go | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/pkg/commands/submodules.go b/pkg/commands/submodules.go index 5c369ab8e..659c2d2d8 100644 --- a/pkg/commands/submodules.go +++ b/pkg/commands/submodules.go @@ -83,13 +83,22 @@ func (c *GitCommand) SubmoduleUpdateAll() error { func (c *GitCommand) SubmoduleDelete(submodule *models.SubmoduleConfig) error { // based on https://gist.github.com/myusuf3/7f645819ded92bda6677 - if err := c.OSCommand.RunCommand("git submodule deinit %s", submodule.Name); err != nil { + if err := c.OSCommand.RunCommand("git submodule deinit --force %s", submodule.Path); err != nil { return err } - if err := c.OSCommand.RunCommand("git rm %s", submodule.Path); err != nil { + if err := c.OSCommand.RunCommand("git rm --force %s", submodule.Path); err != nil { return err } - return os.RemoveAll(filepath.Join(c.DotGitDir, "modules", submodule.Name)) + return os.RemoveAll(filepath.Join(c.DotGitDir, "modules", submodule.Path)) +} + +func (c *GitCommand) AddSubmodule(name string, path string, url string) error { + return c.OSCommand.RunCommand( + "git submodule add --force --name %s -- %s %s ", + c.OSCommand.Quote(name), + c.OSCommand.Quote(url), + c.OSCommand.Quote(path), + ) } |