MCPcopy
hub / github.com/kptdev/kpt / Update

Method Update

internal/util/update/gitpatch.go:50–71  ·  view source on GitHub ↗
(options UpdateOptions)

Source from the content-addressed store, hash-verified

48}
49
50func (u GitPatchUpdater) Update(options UpdateOptions) error {
51 u.UpdateOptions = options
52 u.packageRef = path.Join(strings.TrimLeft(u.KptFile.Upstream.Git.Directory, "/"),
53 u.ToRef)
54 if err := u.calculatePatch(); err != nil {
55 return err
56 }
57
58 // write the patch to a file instead of applying it
59 if options.DryRun {
60 _, err := io.WriteString(os.Stderr, fmt.Sprintf(
61 "patch can be applied with 'git am -3 --directory %s'\n", options.PackagePath))
62 if err != nil {
63 return err
64 }
65 _, err = io.WriteString(options.Output, u.patch)
66 return err
67 }
68
69 // apply the patch to pkg
70 return u.patchLocalPackage()
71}
72
73// calculatePatch runs a series of git commands to calculate a patch which can be used
74// to update the local package

Callers

nothing calls this directly

Calls 2

calculatePatchMethod · 0.95
patchLocalPackageMethod · 0.95

Tested by

no test coverage detected