MCPcopy
hub / github.com/cyclops-ui/cyclops / resolveDefaultBranchRef

Function resolveDefaultBranchRef

cyclops-ctrl/pkg/template/git.go:331–358  ·  view source on GitHub ↗
(repo string, creds *auth.Credentials)

Source from the content-addressed store, hash-verified

329}
330
331func resolveDefaultBranchRef(repo string, creds *auth.Credentials) (string, error) {
332 rem := git.NewRemote(memory.NewStorage(), &config.RemoteConfig{
333 Name: "origin",
334 URLs: []string{repo},
335 })
336
337 // We can then use every Remote functions to retrieve wanted information
338 refs, err := rem.List(&git.ListOptions{
339 PeelingOption: git.AppendPeeled,
340 Auth: httpBasicAuthCredentials(creds),
341 })
342 if err != nil {
343 return "", errors.Wrap(err, fmt.Sprintf("repo %s was not cloned successfully; authentication might be required; check if repository exists and you referenced it correctly", repo))
344 }
345
346 // Filters the references list and only keeps tags
347 for _, r := range refs {
348 if r.Name().Short() == plumbing.HEAD.Short() {
349 for _, rr := range refs {
350 if rr.Name().String() == r.Target().String() {
351 return rr.Hash().String(), nil
352 }
353 }
354 }
355 }
356
357 return "", errors.New("failed resolving HEAD ref")
358}
359
360func readValuesFile(fs billy.Filesystem, path string) ([]byte, error) {
361 valuesFile, err := fs.Open(path2.Join(path, "values.yaml"))

Callers 1

resolveRefFunction · 0.85

Calls 2

httpBasicAuthCredentialsFunction · 0.70
ListMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…