MCPcopy Index your code
hub / github.com/dagger/dagger / createBranchWithPatchFile

Function createBranchWithPatchFile

core/changeset.go:1343–1365  ·  view source on GitHub ↗
(ctx context.Context, dir string, branchName string, patch *File, startPoint ...string)

Source from the content-addressed store, hash-verified

1341}
1342
1343func createBranchWithPatchFile(ctx context.Context, dir string, branchName string, patch *File, startPoint ...string) error {
1344 checkoutArgs := []string{"checkout", "-b", branchName}
1345 if len(startPoint) > 0 {
1346 checkoutArgs = append(checkoutArgs, startPoint[0])
1347 }
1348 if err := runGit(ctx, dir, checkoutArgs...); err != nil {
1349 return err
1350 }
1351 if patch != nil {
1352 if err := gitApplyPatchFromFile(ctx, dir, patch); err != nil {
1353 return fmt.Errorf("apply %s patch: %w", branchName, err)
1354 }
1355 }
1356 // Always commit (even if empty) to ensure consistent commit structure
1357 // This is needed so that HEAD~1 references work correctly
1358 if err := runGit(ctx, dir, "add", "-A"); err != nil {
1359 return err
1360 }
1361 if err := runGit(ctx, dir, "commit", "--allow-empty", "-m", branchName); err != nil {
1362 return err
1363 }
1364 return nil
1365}
1366
1367// resolveModifyDeleteConflicts handles conflicts where one side modified and the other deleted.
1368// For LEAVE_CONFLICT_MARKERS, keeps the modified version.

Callers 2

gitMergeWithPatchesFunction · 0.85

Calls 2

runGitFunction · 0.85
gitApplyPatchFromFileFunction · 0.85

Tested by

no test coverage detected