// Ref returns the Hash pointing the given refName func (r *Repository) Ref(name plumbing.ReferenceName, resolved bool) (*plumbing.Reference, error) { if resolved { return storer.ResolveReference(r.s, name) } return r.s.Reference(name) }
func (r *Repository) updateRemoteConfig( remote *Remote, o *CloneOptions, c *config.RemoteConfig, ) error { if !o.SingleBranch { return nil } head, err := storer.ResolveReference(remote.Info().Refs, o.ReferenceName) if err != nil { return err } c.Fetch = []config.RefSpec{ config.RefSpec(fmt.Sprintf(refspecSingleBranch, head.Name().Short(), c.Name)), } cfg, err := r.s.Config() if err != nil { return err } cfg.Remotes[c.Name] = c return r.s.SetConfig(cfg) }
// Ref returns the Hash pointing the given refName func (r *Remote) Ref(name plumbing.ReferenceName, resolved bool) (*plumbing.Reference, error) { if resolved { return storer.ResolveReference(r.upInfo.Refs, name) } return r.upInfo.Refs.Reference(name) }
func getWants(spec []config.RefSpec, localStorer Storer, remoteRefs storer.ReferenceStorer) ([]plumbing.Hash, error) { wantTags := true for _, s := range spec { if !s.IsWildcard() { wantTags = false break } } iter, err := remoteRefs.IterReferences() if err != nil { return nil, err } wants := map[plumbing.Hash]bool{} err = iter.ForEach(func(ref *plumbing.Reference) error { if !config.MatchAny(spec, ref.Name()) { if !ref.IsTag() || !wantTags { return nil } } if ref.Type() == plumbing.SymbolicReference { ref, err = storer.ResolveReference(remoteRefs, ref.Name()) if err != nil { return err } } if ref.Type() != plumbing.HashReference { return nil } hash := ref.Hash() exists, err := commitExists(localStorer, hash) if err != nil { return err } if !exists { wants[hash] = true } return nil }) if err != nil { return nil, err } var result []plumbing.Hash for h := range wants { result = append(result, h) } return result, nil }
// Head returns the reference where HEAD is pointing func (r *Repository) Head() (*plumbing.Reference, error) { return storer.ResolveReference(r.s, plumbing.HEAD) }
func (i *GitUploadPackInfo) Head() *plumbing.Reference { ref, _ := storer.ResolveReference(i.Refs, plumbing.HEAD) return ref }