Rebase rebase patches.
(title, repoRef, repoDir string, rebaseRefs []string)
| 284 | |
| 285 | // Rebase rebase patches. |
| 286 | func Rebase(title, repoRef, repoDir string, rebaseRefs []string) error { |
| 287 | if !fileio.PathExists(repoDir) { |
| 288 | return errors.ErrDirNotExist |
| 289 | } |
| 290 | if !fileio.PathExists(filepath.Join(repoDir, ".git")) { |
| 291 | return errors.ErrNotGitDir |
| 292 | } |
| 293 | |
| 294 | // Change to source dir to execute git command. |
| 295 | if err := os.Chdir(repoDir); err != nil { |
| 296 | return err |
| 297 | } |
| 298 | |
| 299 | var commands []string |
| 300 | commands = append(commands, "git fetch origin") |
| 301 | |
| 302 | for _, rebaseRef := range rebaseRefs { |
| 303 | commands = append(commands, "git checkout "+rebaseRef) |
| 304 | commands = append(commands, "git rebase "+repoRef) |
| 305 | } |
| 306 | |
| 307 | commandLine := strings.Join(commands, " && ") |
| 308 | executor := cmd.NewExecutor(title, commandLine) |
| 309 | executor.SetWorkDir(repoDir) |
| 310 | if output, err := executor.ExecuteOutputLive(); err != nil { |
| 311 | return fmt.Errorf("%s -> %w", output, err) |
| 312 | } |
| 313 | |
| 314 | return nil |
| 315 | } |
| 316 | |
| 317 | // Clean clean git repo. |
| 318 | func Clean(target, repoDir string) error { |
nothing calls this directly
no test coverage detected