Skip to content

Commit 13e2d77

Browse files
author
Your Name
committed
update latest codes
1 parent 2c45a72 commit 13e2d77

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

cmd/git/submodule.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,13 @@ func addFolderAsSubmodules(repoPath, folder string) error {
9999
cmd := exec.Command("git", "ls-files", "--stage", name)
100100
cmd.Dir = repoPath
101101
if out, _ := cmd.Output(); len(out) > 0 && strings.HasPrefix(string(out), "160000") {
102-
fmt.Printf("Skipping %s: already added as a submodule\n", name)
102+
fmt.Printf("Skipping %s: already as submodule\n", name)
103103
alreadyHandled = true
104104
} else {
105105
url, _ := git.GetRemoteURL(absFolder)
106106
parentURL, parentErr := git.GetRemoteURL(repoPath)
107107
if parentErr == nil && url == parentURL {
108-
fmt.Printf("Skipping %s: same repository as parent\n", name)
108+
fmt.Printf("Skipping %s: already as submodule\n", name)
109109
alreadyHandled = true
110110
} else if _, err := os.Stat(absFolder); err == nil {
111111
fmt.Printf("Skipping %s: directory already exists (use 'git submodule add' manually)\n", name)

cmd/git/sync.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ Examples:
3232
fetchCmd.Stderr = os.Stderr
3333
fetchCmd.Run()
3434

35+
fmt.Printf("Initializing missing submodules...\n")
36+
initCmd := exec.Command("git", "submodule", "update", "--init")
37+
initCmd.Dir = repoPath
38+
initCmd.Stdout = os.Stdout
39+
initCmd.Stderr = os.Stderr
40+
initCmd.Run()
41+
3542
fmt.Printf("Updating submodules to latest versions...\n")
3643
updateCmd := exec.Command("git", "submodule", "update", "--remote", "--merge")
3744
updateCmd.Dir = repoPath

0 commit comments

Comments
 (0)