MCPcopy Create free account
hub / github.com/dagger/dagger / gitOctopusMergeWithPatches

Function gitOctopusMergeWithPatches

core/changeset.go:1208–1247  ·  view source on GitHub ↗
(
	ctx context.Context,
	base dagql.ObjectResult[*Directory],
	ourPatch *File,
	otherPatches []*File,
)

Source from the content-addressed store, hash-verified

1206}
1207
1208func gitOctopusMergeWithPatches(
1209 ctx context.Context,
1210 base dagql.ObjectResult[*Directory],
1211 ourPatch *File,
1212 otherPatches []*File,
1213) (*Directory, error) {
1214 return withGitMergeWorkspace(ctx, base, "Changeset.withChangesets git octopus merge", func(workDir string) error {
1215 if err := initGitRepo(ctx, workDir); err != nil {
1216 return err
1217 }
1218 if err := createBranchWithPatchFile(ctx, workDir, "ours", ourPatch); err != nil {
1219 return err
1220 }
1221
1222 branchNames := make([]string, len(otherPatches))
1223 for i, patch := range otherPatches {
1224 branchName := fmt.Sprintf("branch_%d", i)
1225 branchNames[i] = branchName
1226 if err := createBranchWithPatchFile(ctx, workDir, branchName, patch, "HEAD~1"); err != nil {
1227 return err
1228 }
1229 }
1230
1231 if err := runGit(ctx, workDir, "checkout", "ours"); err != nil {
1232 return err
1233 }
1234
1235 mergeArgs := []string{"merge", "--no-edit", "--no-commit"}
1236 mergeArgs = append(mergeArgs, branchNames...)
1237
1238 if err := runGit(ctx, workDir, mergeArgs...); err != nil {
1239 return err
1240 }
1241
1242 if err := os.RemoveAll(filepath.Join(workDir, ".git")); err != nil {
1243 return fmt.Errorf("remove temporary octopus merge git repository: %w", err)
1244 }
1245 return nil
1246 })
1247}
1248
1249var gitEphemeralConfig = []string{
1250 // These repositories are disposable. Detached maintenance can outlive the

Callers 1

WithChangesetsMethod · 0.85

Calls 5

withGitMergeWorkspaceFunction · 0.85
initGitRepoFunction · 0.85
runGitFunction · 0.85
RemoveAllMethod · 0.45

Tested by

no test coverage detected