本文整理匯總了Golang中gopkg/in/src-d/go-git/v4/plumbing.ReferenceName函數的典型用法代碼示例。如果您正苦於以下問題:Golang ReferenceName函數的具體用法?Golang ReferenceName怎麽用?Golang ReferenceName使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了ReferenceName函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestRefSpecMatch
func (s *RefSpecSuite) TestRefSpecMatch(c *C) {
spec := RefSpec("refs/heads/master:refs/remotes/origin/master")
c.Assert(spec.Match(plumbing.ReferenceName("refs/heads/foo")), Equals, false)
c.Assert(spec.Match(plumbing.ReferenceName("refs/heads/master")), Equals, true)
spec = RefSpec(":refs/heads/master")
c.Assert(spec.Match(plumbing.ReferenceName("")), Equals, true)
c.Assert(spec.Match(plumbing.ReferenceName("refs/heads/master")), Equals, false)
}
示例2: TestMatchAny
func (s *RefSpecSuite) TestMatchAny(c *C) {
specs := []RefSpec{
"refs/heads/bar:refs/remotes/origin/foo",
"refs/heads/foo:refs/remotes/origin/bar",
}
c.Assert(MatchAny(specs, plumbing.ReferenceName("refs/heads/foo")), Equals, true)
c.Assert(MatchAny(specs, plumbing.ReferenceName("refs/heads/bar")), Equals, true)
c.Assert(MatchAny(specs, plumbing.ReferenceName("refs/heads/master")), Equals, false)
}
示例3: TestRefSpecDstBlob
func (s *RefSpecSuite) TestRefSpecDstBlob(c *C) {
spec := RefSpec("refs/heads/*:refs/remotes/origin/*")
c.Assert(
spec.Dst(plumbing.ReferenceName("refs/heads/foo")).String(), Equals,
"refs/remotes/origin/foo",
)
}
示例4: TestDefaultBranch
func (s *RemoteSuite) TestDefaultBranch(c *C) {
r := newRemote(nil, &config.RemoteConfig{Name: "foo", URL: RepositoryFixture})
r.upSrv = &MockGitUploadPackService{}
c.Assert(r.Connect(), IsNil)
c.Assert(r.Head().Name(), Equals, plumbing.ReferenceName("refs/heads/master"))
}
示例5: TestRefSpecDst
func (s *RefSpecSuite) TestRefSpecDst(c *C) {
spec := RefSpec("refs/heads/master:refs/remotes/origin/master")
c.Assert(
spec.Dst(plumbing.ReferenceName("refs/heads/master")).String(), Equals,
"refs/remotes/origin/master",
)
}
示例6: Dst
// Dst returns the destination for the given remote reference
func (s RefSpec) Dst(n plumbing.ReferenceName) plumbing.ReferenceName {
spec := string(s)
start := strings.Index(spec, refSpecSeparator) + 1
dst := spec[start:]
src := s.Src()
if !s.IsWildcard() {
return plumbing.ReferenceName(dst)
}
name := n.String()
ws := strings.Index(src, refSpecWildcard)
wd := strings.Index(dst, refSpecWildcard)
match := name[ws : len(name)-(len(src)-(ws+1))]
return plumbing.ReferenceName(dst[0:wd] + match + dst[wd+1:])
}
示例7: TestDecodeErrorEmpty
func (s *ReportStatusSuite) TestDecodeErrorEmpty(c *C) {
expected := NewReportStatus()
expected.UnpackStatus = "ok"
expected.CommandStatuses = []*CommandStatus{{
ReferenceName: plumbing.ReferenceName("refs/heads/master"),
Status: "ok",
}}
s.testDecodeError(c, "unexpected EOF")
}
示例8: findReference
func findReference(refs []*plumbing.Reference, name string) *plumbing.Reference {
n := plumbing.ReferenceName(name)
for _, ref := range refs {
if ref.Name() == n {
return ref
}
}
return nil
}
示例9: addSymbolicRefs
func (i *GitUploadPackInfo) addSymbolicRefs(ar *advrefs.AdvRefs) error {
if !hasSymrefs(ar) {
return nil
}
for _, symref := range ar.Capabilities.Get("symref").Values {
chunks := strings.Split(symref, ":")
if len(chunks) != 2 {
err := fmt.Errorf("bad number of `:` in symref value (%q)", symref)
return plumbing.NewUnexpectedError(err)
}
name := plumbing.ReferenceName(chunks[0])
target := plumbing.ReferenceName(chunks[1])
ref := plumbing.NewSymbolicReference(name, target)
i.Refs.SetReference(ref)
}
return nil
}
示例10: TestGitUploadPackInfo
func (s *SuiteCommon) TestGitUploadPackInfo(c *C) {
b, _ := base64.StdEncoding.DecodeString(GitUploadPackInfoFixture)
i := NewGitUploadPackInfo()
err := i.Decode(bytes.NewBuffer(b))
c.Assert(err, IsNil)
name := i.Capabilities.SymbolicReference("HEAD")
c.Assert(name, Equals, "refs/heads/master")
c.Assert(i.Refs, HasLen, 4)
ref := i.Refs[plumbing.ReferenceName(name)]
c.Assert(ref, NotNil)
c.Assert(ref.Hash().String(), Equals, "6ecf0ef2c2dffb796033e5a02219af86ec6584e5")
ref = i.Refs[plumbing.HEAD]
c.Assert(ref, NotNil)
c.Assert(ref.Target(), Equals, plumbing.ReferenceName(name))
}
示例11: TestMultipleCommands
func (s *UpdReqEncodeSuite) TestMultipleCommands(c *C) {
hash1 := plumbing.NewHash("1ecf0ef2c2dffb796033e5a02219af86ec6584e5")
hash2 := plumbing.NewHash("2ecf0ef2c2dffb796033e5a02219af86ec6584e5")
r := NewReferenceUpdateRequest()
r.Commands = []*Command{
{Name: plumbing.ReferenceName("myref1"), Old: hash1, New: hash2},
{Name: plumbing.ReferenceName("myref2"), Old: plumbing.ZeroHash, New: hash2},
{Name: plumbing.ReferenceName("myref3"), Old: hash1, New: plumbing.ZeroHash},
}
expected := pktlines(c,
"1ecf0ef2c2dffb796033e5a02219af86ec6584e5 2ecf0ef2c2dffb796033e5a02219af86ec6584e5 myref1\x00",
"0000000000000000000000000000000000000000 2ecf0ef2c2dffb796033e5a02219af86ec6584e5 myref2",
"1ecf0ef2c2dffb796033e5a02219af86ec6584e5 0000000000000000000000000000000000000000 myref3",
pktline.FlushString,
)
s.testEncode(c, r, expected)
}
示例12: TestMultipleCommands
func (s *UpdReqDecodeSuite) TestMultipleCommands(c *C) {
hash1 := plumbing.NewHash("1ecf0ef2c2dffb796033e5a02219af86ec6584e5")
hash2 := plumbing.NewHash("2ecf0ef2c2dffb796033e5a02219af86ec6584e5")
expected := NewReferenceUpdateRequest()
expected.Commands = []*Command{
{Name: plumbing.ReferenceName("myref1"), Old: hash1, New: hash2},
{Name: plumbing.ReferenceName("myref2"), Old: plumbing.ZeroHash, New: hash2},
{Name: plumbing.ReferenceName("myref3"), Old: hash1, New: plumbing.ZeroHash},
}
expected.Packfile = ioutil.NopCloser(bytes.NewReader([]byte{}))
payloads := []string{
"1ecf0ef2c2dffb796033e5a02219af86ec6584e5 2ecf0ef2c2dffb796033e5a02219af86ec6584e5 myref1\x00",
"0000000000000000000000000000000000000000 2ecf0ef2c2dffb796033e5a02219af86ec6584e5 myref2",
"1ecf0ef2c2dffb796033e5a02219af86ec6584e5 0000000000000000000000000000000000000000 myref3",
pktline.FlushString,
}
s.testDecodeOkExpected(c, expected, payloads)
}
示例13: addSymbolicRefs
func addSymbolicRefs(s storer.ReferenceStorer, ar *AdvRefs) error {
if !hasSymrefs(ar) {
return nil
}
for _, symref := range ar.Capabilities.Get(capability.SymRef) {
chunks := strings.Split(symref, ":")
if len(chunks) != 2 {
err := fmt.Errorf("bad number of `:` in symref value (%q)", symref)
return plumbing.NewUnexpectedError(err)
}
name := plumbing.ReferenceName(chunks[0])
target := plumbing.ReferenceName(chunks[1])
ref := plumbing.NewSymbolicReference(name, target)
if err := s.SetReference(ref); err != nil {
return nil
}
}
return nil
}
示例14: TestDecodeErrorPrematureFlush
func (s *ReportStatusSuite) TestDecodeErrorPrematureFlush(c *C) {
expected := NewReportStatus()
expected.UnpackStatus = "ok"
expected.CommandStatuses = []*CommandStatus{{
ReferenceName: plumbing.ReferenceName("refs/heads/master"),
Status: "ok",
}}
s.testDecodeError(c, "premature flush",
pktline.FlushString,
)
}
示例15: TestEncodeDecodeOkMoreReferences
func (s *ReportStatusSuite) TestEncodeDecodeOkMoreReferences(c *C) {
rs := NewReportStatus()
rs.UnpackStatus = "ok"
rs.CommandStatuses = []*CommandStatus{{
ReferenceName: plumbing.ReferenceName("refs/heads/master"),
Status: "ok",
}, {
ReferenceName: plumbing.ReferenceName("refs/heads/a"),
Status: "ok",
}, {
ReferenceName: plumbing.ReferenceName("refs/heads/b"),
Status: "ok",
}}
s.testEncodeDecodeOk(c, rs,
"unpack ok\n",
"ok refs/heads/master\n",
"ok refs/heads/a\n",
"ok refs/heads/b\n",
pktline.FlushString,
)
}