0
0
mirror of https://github.com/thegeeklab/wp-git-clone.git synced 2024-11-24 23:10:40 +00:00
wp-git-clone/git/submodule.go

32 lines
551 B
Go
Raw Normal View History

2023-12-22 23:59:23 +00:00
package git
import (
"os"
plugin_exec "github.com/thegeeklab/wp-plugin-go/v3/exec"
2023-12-22 23:59:23 +00:00
)
// SubmoduleUpdate recursively initializes and updates submodules.
func (r *Repository) SubmoduleUpdate() *plugin_exec.Cmd {
2023-12-22 23:59:23 +00:00
args := []string{
"submodule",
"update",
"--init",
"--recursive",
}
if r.SubmodulePartial {
2023-12-22 23:59:23 +00:00
args = append(args, "--depth=1", "--recommend-shallow")
}
if r.SubmoduleRemote {
args = append(args, "--remote")
2023-12-22 23:59:23 +00:00
}
cmd := plugin_exec.Command(gitBin, args...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
return cmd
2023-12-22 23:59:23 +00:00
}