MCPcopy Create free account
hub / github.com/celer-pkg/celer / Rebase

Function Rebase

pkgs/git/control.go:286–315  ·  view source on GitHub ↗

Rebase rebase patches.

(title, repoRef, repoDir string, rebaseRefs []string)

Source from the content-addressed store, hash-verified

284
285// Rebase rebase patches.
286func 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.
318func Clean(target, repoDir string) error {

Callers

nothing calls this directly

Calls 4

PathExistsFunction · 0.92
NewExecutorFunction · 0.92
SetWorkDirMethod · 0.80
ExecuteOutputLiveMethod · 0.80

Tested by

no test coverage detected