MCPcopy Create free account
hub / github.com/remind101/deploy / Ref

Function Ref

deploy.go:326–341  ·  view source on GitHub ↗

Ref attempts to return the proper git ref to deploy. If a ref is provided, that will be returned. If not, it will fallback to calling headFunc. If an error is returned (not in a git repo), then it will fallback to DefaultRef.

(ref string, headFunc func() (string, error))

Source from the content-addressed store, hash-verified

324// that will be returned. If not, it will fallback to calling headFunc. If an
325// error is returned (not in a git repo), then it will fallback to DefaultRef.
326func Ref(ref string, headFunc func() (string, error)) string {
327 if ref != "" {
328 return ref
329 }
330
331 ref, err := headFunc()
332 if err != nil {
333 // An error means that we're either not in a GitRepo or we're
334 // not on a branch. In this case, we just fallback to the
335 // DefaultRef.
336 return DefaultRef
337 }
338
339 // Convert `refs/heads/test-deploy` => `test-deploy`
340 return refRegex.ReplaceAllString(ref, "$1")
341}
342
343// Repo will determine the correct GitHub repo to deploy to, based on a set of
344// arguments.

Callers 2

TestRefFunction · 0.85
RunDeployFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestRefFunction · 0.68