UpdateSubmodules update git submodules.
(title, repoDir string)
| 134 | |
| 135 | // UpdateSubmodules update git submodules. |
| 136 | func UpdateSubmodules(title, repoDir string) error { |
| 137 | if !fileio.PathExists(repoDir) { |
| 138 | return errors.ErrDirNotExist |
| 139 | } |
| 140 | if !fileio.PathExists(filepath.Join(repoDir, ".git")) { |
| 141 | return errors.ErrNotGitDir |
| 142 | } |
| 143 | |
| 144 | if !fileio.PathExists(filepath.Join(repoDir, ".gitmodules")) { |
| 145 | return nil |
| 146 | } |
| 147 | |
| 148 | command := "git submodule update --init --recursive" |
| 149 | executor := cmd.NewExecutor(title, command) |
| 150 | executor.SetWorkDir(repoDir) |
| 151 | if output, err := executor.ExecuteOutputLive(); err != nil { |
| 152 | return fmt.Errorf("failed to update submodules: %s -> %w", output, err) |
| 153 | } |
| 154 | return nil |
| 155 | } |
| 156 | |
| 157 | // UpdateRepo update git repo. |
| 158 | func UpdateRepo(target, repoRef, repoDir string, force bool) error { |
no test coverage detected