CherryPick cherry-pick patches.
(title, repoDir string, patches []string)
| 253 | |
| 254 | // CherryPick cherry-pick patches. |
| 255 | func CherryPick(title, repoDir string, patches []string) error { |
| 256 | if !fileio.PathExists(repoDir) { |
| 257 | return errors.ErrDirNotExist |
| 258 | } |
| 259 | if !fileio.PathExists(filepath.Join(repoDir, ".git")) { |
| 260 | return errors.ErrNotGitDir |
| 261 | } |
| 262 | |
| 263 | // Change to source dir to execute git command. |
| 264 | if err := os.Chdir(repoDir); err != nil { |
| 265 | return err |
| 266 | } |
| 267 | |
| 268 | var commands []string |
| 269 | commands = append(commands, "git fetch origin") |
| 270 | |
| 271 | for _, patch := range patches { |
| 272 | commands = append(commands, "git cherry-pick "+patch) |
| 273 | } |
| 274 | |
| 275 | commandLine := strings.Join(commands, " && ") |
| 276 | executor := cmd.NewExecutor(title, commandLine) |
| 277 | executor.SetWorkDir(repoDir) |
| 278 | if output, err := executor.ExecuteOutputLive(); err != nil { |
| 279 | return fmt.Errorf("%s -> %w", output, err) |
| 280 | } |
| 281 | |
| 282 | return nil |
| 283 | } |
| 284 | |
| 285 | // Rebase rebase patches. |
| 286 | func Rebase(title, repoRef, repoDir string, rebaseRefs []string) error { |
nothing calls this directly
no test coverage detected