summaryrefslogtreecommitdiffstats
path: root/pkg/commands
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2020-09-30 21:12:03 +1000
committerJesse Duffield <jessedduffield@gmail.com>2020-10-02 08:09:42 +1000
commitd4ab607d0dd94f73eb1dcd4ba9842eb86b6aa0f4 (patch)
tree4cb72d33183f60fc8a943dd35d7299ce07d44cee /pkg/commands
parentea307c8d94623bd0279297db2cf3990492998ab4 (diff)
allow adding a submodule
Diffstat (limited to 'pkg/commands')
-rw-r--r--pkg/commands/submodules.go15
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),
+ )
}