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

Method listRemoteRefs

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

Source from the content-addressed store, hash-verified

275}
276
277func (r Repo) listRemoteRefs(repo string, creds *auth.Credentials) ([]string, error) {
278 rem := git.NewRemote(memory.NewStorage(), &config.RemoteConfig{
279 Name: "origin",
280 URLs: []string{repo},
281 })
282
283 refs, err := rem.List(&git.ListOptions{
284 PeelingOption: git.AppendPeeled,
285 Auth: httpBasicAuthCredentials(creds),
286 })
287 if err != nil {
288 return nil, 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))
289 }
290
291 branches := make([]string, 0)
292
293 for _, ref := range refs {
294 if ref.Name().IsBranch() {
295 branches = append(branches, ref.Name().Short())
296 }
297 }
298
299 return branches, nil
300}
301
302func resolveRef(repo, version string, creds *auth.Credentials) (string, error) {
303 if len(version) == 0 {

Callers 1

GetTemplateRevisionsMethod · 0.95

Calls 2

httpBasicAuthCredentialsFunction · 0.70
ListMethod · 0.65

Tested by

no test coverage detected