2023-12-22 23:59:23 +00:00
|
|
|
package git
|
|
|
|
|
|
|
|
import (
|
2024-05-06 18:30:18 +00:00
|
|
|
"github.com/thegeeklab/wp-plugin-go/v2/types"
|
2023-12-22 23:59:23 +00:00
|
|
|
"golang.org/x/sys/execabs"
|
|
|
|
)
|
|
|
|
|
|
|
|
// SubmoduleUpdate recursively initializes and updates submodules.
|
2024-05-06 18:30:18 +00:00
|
|
|
func (r *Repository) SubmoduleUpdate() *types.Cmd {
|
2023-12-22 23:59:23 +00:00
|
|
|
args := []string{
|
|
|
|
"submodule",
|
|
|
|
"update",
|
|
|
|
"--init",
|
|
|
|
"--recursive",
|
|
|
|
}
|
|
|
|
|
2024-05-06 18:30:18 +00:00
|
|
|
if r.SubmodulePartial {
|
2023-12-22 23:59:23 +00:00
|
|
|
args = append(args, "--depth=1", "--recommend-shallow")
|
|
|
|
}
|
|
|
|
|
2024-05-06 18:30:18 +00:00
|
|
|
if r.SubmoduleRemote {
|
|
|
|
args = append(args, "--remote")
|
2023-12-22 23:59:23 +00:00
|
|
|
}
|
|
|
|
|
2024-05-06 18:30:18 +00:00
|
|
|
return &types.Cmd{
|
|
|
|
Cmd: execabs.Command(gitBin, args...),
|
|
|
|
}
|
2023-12-22 23:59:23 +00:00
|
|
|
}
|