Exemplo n.º 1
0
// New returns a pointer to a new UlReq value, ready to be used.  It has
// no capabilities, wants or shallows and an infinite depth.  Please
// note that to encode an upload-request it has to have at least one
// wanted hash.
func New() *UlReq {
	return &UlReq{
		Capabilities: packp.NewCapabilities(),
		Wants:        []plumbing.Hash{},
		Shallows:     []plumbing.Hash{},
		Depth:        DepthCommits(0),
	}
}
Exemplo n.º 2
0
// New returns a pointer to a new AdvRefs value, ready to be used.
func New() *AdvRefs {
	return &AdvRefs{
		Prefix:       [][]byte{},
		Capabilities: packp.NewCapabilities(),
		References:   make(map[string]plumbing.Hash),
		Peeled:       make(map[string]plumbing.Hash),
		Shallows:     []plumbing.Hash{},
	}
}
Exemplo n.º 3
0
func (s *SuiteEncoder) TestAll(c *C) {
	hash := plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")

	capabilities := packp.NewCapabilities()
	capabilities.Add("symref", "HEAD:/refs/heads/master")
	capabilities.Add("ofs-delta")
	capabilities.Add("multi_ack")

	references := map[string]plumbing.Hash{
		"refs/heads/master":      plumbing.NewHash("a6930aaee06755d1bdcfd943fbf614e4d92bb0c7"),
		"refs/tags/v2.6.12-tree": plumbing.NewHash("1111111111111111111111111111111111111111"),
		"refs/tags/v2.7.13-tree": plumbing.NewHash("3333333333333333333333333333333333333333"),
		"refs/tags/v2.6.13-tree": plumbing.NewHash("2222222222222222222222222222222222222222"),
		"refs/tags/v2.6.11-tree": plumbing.NewHash("5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c"),
	}

	peeled := map[string]plumbing.Hash{
		"refs/tags/v2.7.13-tree": plumbing.NewHash("4444444444444444444444444444444444444444"),
		"refs/tags/v2.6.12-tree": plumbing.NewHash("5555555555555555555555555555555555555555"),
	}

	shallows := []plumbing.Hash{
		plumbing.NewHash("1111111111111111111111111111111111111111"),
		plumbing.NewHash("4444444444444444444444444444444444444444"),
		plumbing.NewHash("3333333333333333333333333333333333333333"),
		plumbing.NewHash("2222222222222222222222222222222222222222"),
	}

	ar := &advrefs.AdvRefs{
		Head:         &hash,
		Capabilities: capabilities,
		References:   references,
		Peeled:       peeled,
		Shallows:     shallows,
	}

	expected := pktlines(c,
		[]byte("6ecf0ef2c2dffb796033e5a02219af86ec6584e5 HEAD\x00multi_ack ofs-delta symref=HEAD:/refs/heads/master\n"),
		[]byte("a6930aaee06755d1bdcfd943fbf614e4d92bb0c7 refs/heads/master\n"),
		[]byte("5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c refs/tags/v2.6.11-tree\n"),
		[]byte("1111111111111111111111111111111111111111 refs/tags/v2.6.12-tree\n"),
		[]byte("5555555555555555555555555555555555555555 refs/tags/v2.6.12-tree^{}\n"),
		[]byte("2222222222222222222222222222222222222222 refs/tags/v2.6.13-tree\n"),
		[]byte("3333333333333333333333333333333333333333 refs/tags/v2.7.13-tree\n"),
		[]byte("4444444444444444444444444444444444444444 refs/tags/v2.7.13-tree^{}\n"),
		[]byte("shallow 1111111111111111111111111111111111111111\n"),
		[]byte("shallow 2222222222222222222222222222222222222222\n"),
		[]byte("shallow 3333333333333333333333333333333333333333\n"),
		[]byte("shallow 4444444444444444444444444444444444444444\n"),
		pktline.Flush,
	)

	testEncode(c, ar, expected)
}
Exemplo n.º 4
0
func (s *SuiteEncoder) TestCapsNoHead(c *C) {
	capabilities := packp.NewCapabilities()
	capabilities.Add("symref", "HEAD:/refs/heads/master")
	capabilities.Add("ofs-delta")
	capabilities.Add("multi_ack")
	ar := &advrefs.AdvRefs{
		Capabilities: capabilities,
	}

	expected := pktlines(c,
		[]byte("0000000000000000000000000000000000000000 capabilities^{}\x00multi_ack ofs-delta symref=HEAD:/refs/heads/master\n"),
		pktline.Flush,
	)

	testEncode(c, ar, expected)
}
Exemplo n.º 5
0
func (s *SuiteEncoder) TestCapsWithHead(c *C) {
	hash := plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")
	capabilities := packp.NewCapabilities()
	capabilities.Add("symref", "HEAD:/refs/heads/master")
	capabilities.Add("ofs-delta")
	capabilities.Add("multi_ack")
	ar := &advrefs.AdvRefs{
		Head:         &hash,
		Capabilities: capabilities,
	}

	expected := pktlines(c,
		[]byte("6ecf0ef2c2dffb796033e5a02219af86ec6584e5 HEAD\x00multi_ack ofs-delta symref=HEAD:/refs/heads/master\n"),
		pktline.Flush,
	)

	testEncode(c, ar, expected)
}
Exemplo n.º 6
0
func (p *MockGitUploadPackService) Info() (*common.GitUploadPackInfo, error) {
	if !p.connected {
		return nil, errors.New("not connected")
	}

	h := fixtures.ByURL(p.endpoint.String()).One().Head

	c := packp.NewCapabilities()
	c.Decode("6ecf0ef2c2dffb796033e5a02219af86ec6584e5 HEADmulti_ack thin-pack side-band side-band-64k ofs-delta shallow no-progress include-tag multi_ack_detailed no-done symref=HEAD:refs/heads/master agent=git/2:2.4.8~dbussink-fix-enterprise-tokens-compilation-1167-gc7006cf")

	ref := plumbing.ReferenceName("refs/heads/master")
	branch := plumbing.ReferenceName("refs/heads/branch")
	tag := plumbing.ReferenceName("refs/tags/v1.0.0")

	return &common.GitUploadPackInfo{
		Capabilities: c,
		Refs: map[plumbing.ReferenceName]*plumbing.Reference{
			plumbing.HEAD: plumbing.NewSymbolicReference(plumbing.HEAD, ref),
			ref:           plumbing.NewHashReference(ref, h),
			tag:           plumbing.NewHashReference(tag, h),
			branch:        plumbing.NewHashReference(branch, plumbing.NewHash("e8d3ffab552895c19b9fcf7aa264d277cde33881")),
		},
	}, nil
}
Exemplo n.º 7
0
func (s *SuiteCommon) TestCapabilitiesSymbolicReference(c *C) {
	cap := packp.NewCapabilities()
	cap.Decode(CapabilitiesFixture)
	c.Assert(cap.SymbolicReference("HEAD"), Equals, "refs/heads/master")
}
Exemplo n.º 8
0
func NewGitUploadPackInfo() *GitUploadPackInfo {
	return &GitUploadPackInfo{
		Capabilities: packp.NewCapabilities(),
		Refs:         make(memory.ReferenceStorage, 0),
	}
}