MCPcopy Index your code
hub / github.com/jetify-com/devbox / removePatch

Method removePatch

internal/devconfig/configfile/ast.go:221–247  ·  view source on GitHub ↗

removePatch removes the patch field from the named package.

(name string)

Source from the content-addressed store, hash-verified

219
220// removePatch removes the patch field from the named package.
221func (c *configAST) removePatch(name string) {
222 pkgs := c.packagesField(false)
223 obj, ok := pkgs.Value.Value.(*hujson.Object)
224 if !ok {
225 // Packages field is an array.
226 return
227 }
228 i := c.memberIndex(obj, name)
229 if i == -1 {
230 // Package not found.
231 return
232 }
233
234 obj, ok = obj.Members[i].Value.Value.(*hujson.Object)
235 if !ok {
236 // Package is a string, not an object.
237 return
238 }
239 i = c.memberIndex(obj, "patch")
240 if i == -1 {
241 // Patch field doesn't exist.
242 return
243 }
244
245 obj.Members = slices.Delete(obj.Members, i, i+1)
246 c.root.Format()
247}
248
249// setPatch sets the patch field of the named package.
250func (c *configAST) setPatch(name string, mode PatchMode) {

Callers 1

SetPatchMethod · 0.80

Calls 3

packagesFieldMethod · 0.95
memberIndexMethod · 0.95
FormatMethod · 0.45

Tested by

no test coverage detected