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

Function CherryPick

pkgs/git/control.go:255–283  ·  view source on GitHub ↗

CherryPick cherry-pick patches.

(title, repoDir string, patches []string)

Source from the content-addressed store, hash-verified

253
254// CherryPick cherry-pick patches.
255func 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.
286func Rebase(title, repoRef, repoDir string, rebaseRefs []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