當前位置: 首頁>>代碼示例>>Golang>>正文


Golang plumbing.Reference類代碼示例

本文整理匯總了Golang中gopkg/in/src-d/go-git/v4/plumbing.Reference的典型用法代碼示例。如果您正苦於以下問題:Golang Reference類的具體用法?Golang Reference怎麽用?Golang Reference使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Reference類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: SetReference

func (r ReferenceStorage) SetReference(ref *plumbing.Reference) error {
	if ref != nil {
		r[ref.Name()] = ref
	}

	return nil
}
開發者ID:alcortesm,項目名稱:go-git,代碼行數:7,代碼來源:storage.go

示例2: buildGitUploadPackInfo

func (s *Server) buildGitUploadPackInfo(ref *plumbing.Reference) *common.GitUploadPackInfo {
	info := common.NewGitUploadPackInfo()
	info.Refs.SetReference(ref)
	info.Refs.SetReference(plumbing.NewSymbolicReference(plumbing.HEAD, ref.Name()))
	info.Capabilities.Set("symref", "HEAD:"+ref.Name().String())

	return info
}
開發者ID:mcuadros,項目名稱:gop.kg,代碼行數:8,代碼來源:proxy.go

示例3: AddReference

func (a *AdvRefs) AddReference(r *plumbing.Reference) error {
	switch r.Type() {
	case plumbing.SymbolicReference:
		v := fmt.Sprintf("%s:%s", r.Name().String(), r.Target().String())
		a.Capabilities.Add(capability.SymRef, v)
	case plumbing.HashReference:
		a.References[r.Name().String()] = r.Hash()
	default:
		return plumbing.ErrInvalidType
	}

	return nil
}
開發者ID:src-d,項目名稱:go-git,代碼行數:13,代碼來源:advrefs.go

示例4: SetReference

func (s *Storage) SetReference(ref *plumbing.Reference) error {
	key, err := s.buildReferenceKey(ref.Name())
	if err != nil {
		return err
	}

	raw := ref.Strings()
	bins := driver.BinMap{
		urlField: s.url,
		"name":   raw[0],
		"target": raw[1],
	}

	return s.client.Put(nil, key, bins)
}
開發者ID:src-d,項目名稱:go-git,代碼行數:15,代碼來源:storage.go

示例5: Fetch

func (f *Fetcher) Fetch(w io.Writer, ref *plumbing.Reference) (written int64, err error) {
	if err := f.service.Connect(); err != nil {
		return 0, err
	}

	req := &common.GitUploadPackRequest{}
	req.Want(ref.Hash())

	r, err := f.service.Fetch(req)
	if err != nil {
		return 0, err
	}

	return io.Copy(w, r)
}
開發者ID:mcuadros,項目名稱:gop.kg,代碼行數:15,代碼來源:fetcher.go

示例6: resolveReference

func resolveReference(s ReferenceStorer, r *plumbing.Reference, recursion int) (*plumbing.Reference, error) {
	if r.Type() != plumbing.SymbolicReference {
		return r, nil
	}

	if recursion > MaxResolveRecursion {
		return nil, ErrMaxResolveRecursion
	}

	t, err := s.Reference(r.Target())
	if err != nil {
		return nil, err
	}

	recursion++
	return resolveReference(s, t, recursion)
}
開發者ID:src-d,項目名稱:go-git,代碼行數:17,代碼來源:reference.go

示例7: addReferenceIfRefSpecMatches

func (r *Remote) addReferenceIfRefSpecMatches(rs config.RefSpec,
	remoteRefs storer.ReferenceStorer, localRef *plumbing.Reference,
	req *packp.ReferenceUpdateRequest) error {

	if localRef.Type() != plumbing.HashReference {
		return nil
	}

	if !rs.Match(localRef.Name()) {
		return nil
	}

	dstName := rs.Dst(localRef.Name())
	oldHash := plumbing.ZeroHash
	newHash := localRef.Hash()

	iter, err := remoteRefs.IterReferences()
	if err != nil {
		return err
	}

	err = iter.ForEach(func(remoteRef *plumbing.Reference) error {
		if remoteRef.Type() != plumbing.HashReference {
			return nil
		}

		if dstName != remoteRef.Name() {
			return nil
		}

		oldHash = remoteRef.Hash()
		return nil
	})

	if oldHash == newHash {
		return nil
	}

	req.Commands = append(req.Commands, &packp.Command{
		Name: dstName,
		Old:  oldHash,
		New:  newHash,
	})
	return nil
}
開發者ID:src-d,項目名稱:go-git,代碼行數:45,代碼來源:remote.go

示例8: SetRef

func (d *DotGit) SetRef(r *plumbing.Reference) error {
	var content string
	switch r.Type() {
	case plumbing.SymbolicReference:
		content = fmt.Sprintf("ref: %s\n", r.Target())
	case plumbing.HashReference:
		content = fmt.Sprintln(r.Hash().String())
	}

	f, err := d.fs.Create(r.Name().String())
	if err != nil {
		return err
	}

	if _, err := f.Write([]byte(content)); err != nil {
		return err
	}
	return f.Close()
}
開發者ID:alcortesm,項目名稱:go-git,代碼行數:19,代碼來源:dotgit.go

示例9: createReferences

func (r *Repository) createReferences(ref *plumbing.Reference) error {
	if !ref.IsBranch() {
		// detached HEAD mode
		head := plumbing.NewHashReference(plumbing.HEAD, ref.Hash())
		return r.s.SetReference(head)
	}

	if err := r.s.SetReference(ref); err != nil {
		return err
	}

	head := plumbing.NewSymbolicReference(plumbing.HEAD, ref.Name())
	return r.s.SetReference(head)
}
開發者ID:alcortesm,項目名稱:go-git,代碼行數:14,代碼來源:repository.go

示例10: mutateTagToBranch

// we mutate the tag into a branch to avoid detached branches
func (s *Server) mutateTagToBranch(ref *plumbing.Reference, constraint string) *plumbing.Reference {
	branch := plumbing.ReferenceName(fmt.Sprintf("refs/heads/%s", constraint))
	return plumbing.NewHashReference(branch, ref.Hash())
}
開發者ID:mcuadros,項目名稱:gop.kg,代碼行數:5,代碼來源:proxy.go


注:本文中的gopkg/in/src-d/go-git/v4/plumbing.Reference類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。