summaryrefslogtreecommitdiffstats
path: root/pkg/commands
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2020-10-01 22:13:32 +1000
committerJesse Duffield <jessedduffield@gmail.com>2020-10-02 08:09:42 +1000
commit2dc848506cb465cd46006b4a2a6dca2bdc5cf89d (patch)
tree58ea3cbafe116ced5bd7fbf7197c6cecc6ac0db8 /pkg/commands
parent9125e3c0c6f9c2f83ba74f33b5899054b8641218 (diff)
bulk submodule menu
Diffstat (limited to 'pkg/commands')
-rw-r--r--pkg/commands/files.go8
-rw-r--r--pkg/commands/submodules.go36
2 files changed, 36 insertions, 8 deletions
diff --git a/pkg/commands/files.go b/pkg/commands/files.go
index d4560076f..05aa89978 100644
--- a/pkg/commands/files.go
+++ b/pkg/commands/files.go
@@ -251,13 +251,7 @@ func (c *GitCommand) ResetAndClean() error {
}
if len(submoduleConfigs) > 0 {
- for _, config := range submoduleConfigs {
- if err := c.SubmoduleStash(config); err != nil {
- return err
- }
- }
-
- if err := c.SubmoduleUpdateAll(); err != nil {
+ if err := c.ResetSubmodules(submoduleConfigs); err != nil {
return err
}
}
diff --git a/pkg/commands/submodules.go b/pkg/commands/submodules.go
index 1444890f7..53a201c1e 100644
--- a/pkg/commands/submodules.go
+++ b/pkg/commands/submodules.go
@@ -123,7 +123,15 @@ func (c *GitCommand) SubmoduleUpdateUrl(name string, path string, newUrl string)
return err
}
- return c.OSCommand.RunCommand("git submodule sync %s", path)
+ if err := c.OSCommand.RunCommand("git submodule sync %s", path); err != nil {
+ return err
+ }
+
+ if err := c.OSCommand.RunCommand("git submodule update --init %s", path); err != nil {
+ return err
+ }
+
+ return nil
}
func (c *GitCommand) SubmoduleInit(path string) error {
@@ -133,3 +141,29 @@ func (c *GitCommand) SubmoduleInit(path string) error {
func (c *GitCommand) SubmoduleUpdate(path string) error {
return c.OSCommand.RunCommand("git submodule update --init %s", path)
}
+
+func (c *GitCommand) SubmoduleBulkInitCmdStr() string {
+ return "git submodule init"
+}
+
+func (c *GitCommand) SubmoduleBulkUpdateCmdStr() string {
+ return "git submodule update"
+}
+
+func (c *GitCommand) SubmoduleForceBulkUpdateCmdStr() string {
+ return "git submodule update --force"
+}
+
+func (c *GitCommand) SubmoduleBulkDeinitCmdStr() string {
+ return "git submodule deinit --all --force"
+}
+
+func (c *GitCommand) ResetSubmodules(submodules []*models.SubmoduleConfig) error {
+ for _, submodule := range submodules {
+ if err := c.SubmoduleStash(submodule); err != nil {
+ return err
+ }
+ }
+
+ return c.SubmoduleUpdateAll()
+}