MCPcopy Create free account
hub / github.com/docker/secrets-engine / remoteDefaultBranch

Function remoteDefaultBranch

x/release/command.go:327–336  ·  view source on GitHub ↗

remoteDefaultBranch resolves origin's default branch, falling back to "main" when origin/HEAD is not configured locally.

(ctx context.Context)

Source from the content-addressed store, hash-verified

325// remoteDefaultBranch resolves origin's default branch, falling back to "main"
326// when origin/HEAD is not configured locally.
327func remoteDefaultBranch(ctx context.Context) string {
328 out, err := runGit(ctx, "symbolic-ref", "--short", "refs/remotes/origin/HEAD")
329 if err != nil {
330 fmt.Fprintf(os.Stderr,
331 "warning: origin/HEAD is not set; assuming default branch is %q — "+
332 "run 'git remote set-head origin -a' if the real default differs\n", "main")
333 return "main"
334 }
335 return strings.TrimPrefix(strings.TrimSpace(out), "origin/")
336}
337
338func revParse(ctx context.Context, ref string) (string, error) {
339 out, err := runGit(ctx, "rev-parse", ref)

Callers 1

verifyReleaseRefFunction · 0.85

Calls 1

runGitFunction · 0.85

Tested by

no test coverage detected