当前位置: 首页>>代码示例>>Golang>>正文


Golang objects.ObjectId类代码示例

本文整理汇总了Golang中github.com/jbrukh/ggit/api/objects.ObjectId的典型用法代码示例。如果您正苦于以下问题:Golang ObjectId类的具体用法?Golang ObjectId怎么用?Golang ObjectId使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ObjectId类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: parseDeltaEntry

func (p *Pack) parseDeltaEntry(bytes []byte, pot PackedObjectType, oid *objects.ObjectId, i int) *PackedObject {
	var (
		deltaDeflated packedDelta
		baseOffset    int64
		dp            *packedObjectParser
		err           error
	)
	e := p.idx.entries[i]
	switch pot {
	case ObjectRefDelta:
		var oid *objects.ObjectId
		deltaDeflated, oid = readPackedRefDelta(bytes)
		e := p.idx.entryById(oid)
		if e == nil {
			util.PanicErrf("nil entry for base object with id %s", oid.String())
		}
		baseOffset = e.offset
	case ObjectOffsetDelta:
		if deltaDeflated, baseOffset, err = readPackedOffsetDelta(bytes); err != nil {
			util.PanicErrf("Err parsing size: %v. Could not determine size for %s", err, e.String())
		}
		baseOffset = e.offset - baseOffset
	}
	base := p.findObjectByOffset(baseOffset)
	bytes = []byte(deltaDeflated)
	if dp, err = newPackedObjectParser(bytes, oid); err != nil {
		util.PanicErr(err.Error())
	}
	return dp.applyDelta(base, oid)
}
开发者ID:jbrukh,项目名称:ggit,代码行数:30,代码来源:pack.go

示例2: testFirstParent

func testFirstParent(t *testing.T, repo Repository, oid *objects.ObjectId, parentOid *objects.ObjectId) {
	rev := oid.String() // rev == oid here
	testObjectExpected(t, repo, rev, oid, objects.ObjectCommit)
	for i := 4; i <= 40; i++ {
		testObjectExpected(t, repo, rev[:i]+"^", parentOid, objects.ObjectCommit)
	}
}
开发者ID:jbrukh,项目名称:ggit,代码行数:7,代码来源:rev_parser_git_test.go

示例3: testFirstParentVariations

func testFirstParentVariations(t *testing.T, repo Repository, oid *objects.ObjectId, parentOid *objects.ObjectId) {
	rev := oid.String()
	testObjectExpected(t, repo, rev+"^", parentOid, objects.ObjectCommit)
	testObjectExpected(t, repo, rev+"^1", parentOid, objects.ObjectCommit)
	testObjectExpected(t, repo, rev+"~", parentOid, objects.ObjectCommit)
	testObjectExpected(t, repo, rev+"~1", parentOid, objects.ObjectCommit)
}
开发者ID:jbrukh,项目名称:ggit,代码行数:7,代码来源:rev_parser_git_test.go

示例4: Test_ParseObjectId

func Test_ParseObjectId(t *testing.T) {
	var oid *objects.ObjectId
	oidStr := "ff6ccb68859fd52216ec8dadf98d2a00859f5369"
	t1 := ObjectParserForString(oidStr)
	oid = t1.ParseOid()
	util.Assert(t, oid.String() == oidStr)
}
开发者ID:jbrukh,项目名称:ggit,代码行数:7,代码来源:object_parser_test.go

示例5: testShortOid

// testShortOid retrives the object by all possible combinations of
// shortening its id.
func testShortOid(t *testing.T, repo Repository, oid *objects.ObjectId) {
	rev := oid.String()
	for i := 4; i <= 40; i++ {
		o, err := ObjectFromRevision(repo, rev[:i])
		util.AssertNoErr(t, err)
		util.AssertEqualString(t, o.ObjectId().String(), oid.String())
	}
}
开发者ID:jbrukh,项目名称:ggit,代码行数:10,代码来源:rev_parser_git_test.go

示例6: testParentlessCommit

func testParentlessCommit(t *testing.T, repo Repository, oid *objects.ObjectId) {
	rev := oid.String()
	testObjectExpected(t, repo, rev, oid, objects.ObjectCommit)
	_, err := ObjectFromRevision(repo, rev+"~1")
	util.Assert(t, err != nil)
	_, err = ObjectFromRevision(repo, rev+"^")
	util.Assert(t, err != nil)
}
开发者ID:jbrukh,项目名称:ggit,代码行数:8,代码来源:rev_parser_git_test.go

示例7: testSecondAncestorVariations

func testSecondAncestorVariations(t *testing.T, repo Repository, oid *objects.ObjectId, parentOid *objects.ObjectId) {
	rev := oid.String()
	testObjectExpected(t, repo, rev+"^^", parentOid, objects.ObjectCommit)
	testObjectExpected(t, repo, rev+"^1^1", parentOid, objects.ObjectCommit)
	testObjectExpected(t, repo, rev+"^^1", parentOid, objects.ObjectCommit)
	testObjectExpected(t, repo, rev+"^1^", parentOid, objects.ObjectCommit)
	testObjectExpected(t, repo, rev+"~~", parentOid, objects.ObjectCommit)
	testObjectExpected(t, repo, rev+"~1~", parentOid, objects.ObjectCommit)
	testObjectExpected(t, repo, rev+"~1~1", parentOid, objects.ObjectCommit)
	testObjectExpected(t, repo, rev+"~~1", parentOid, objects.ObjectCommit)
}
开发者ID:jbrukh,项目名称:ggit,代码行数:11,代码来源:rev_parser_git_test.go

示例8: testPackedTagDerefInfo

func testPackedTagDerefInfo(t *testing.T, repo Repository, spec string, oid *objects.ObjectId) {
	ref, err := repo.Ref(spec)
	util.AssertNoErr(t, err)
	util.AssertEqualString(t, ref.Name(), spec)
	// make sure target is symbolic and matches
	symbolic, target := ref.Target()
	util.Assert(t, !symbolic)
	if target == nil || ref.Commit() == nil {
		t.Fatalf("nil target or commit")
	}
	util.AssertEqualString(t, ref.Commit().String(), oid.String())
}
开发者ID:jbrukh,项目名称:ggit,代码行数:12,代码来源:refs_git_test.go

示例9: assertPeeledRef

func assertPeeledRef(t *testing.T, peeledRef objects.Ref, oid *objects.ObjectId) {
	symbolic, target := peeledRef.Target()
	util.Assert(t, !symbolic)
	if target == nil {
		t.Fatalf("nil target")
	}
	util.AssertEqualString(t, target.(*objects.ObjectId).String(), oid.String())
	util.AssertEqualString(t, peeledRef.ObjectId().String(), oid.String())
	util.AssertPanic(t, func() {
		s := target.(string)
		s += "" // for compilation
	})
}
开发者ID:jbrukh,项目名称:ggit,代码行数:13,代码来源:refs_git_test.go

示例10: entryById

func (idx *Idx) entryById(oid *objects.ObjectId) *PackedObjectId {
	trimmed := idx.entriesWithPrefix(oid.Bytes()[0])
	if trimmed == nil {
		return nil
	}
	id := oid.String()
	if idx.idToEntry[id] != nil {
		return idx.idToEntry[id]
	}
	gte := func(i int) bool {
		var oid *objects.ObjectId
		oid = trimmed[i].ObjectId
		return oid.String() >= id
	}
	i := sort.Search(len(trimmed), gte)
	if i >= len(trimmed) {
		return nil
	}
	result := trimmed[i]
	if result.ObjectId.String() != id {
		return nil
	}
	idx.idToEntry[id] = result
	return result
}
开发者ID:jbrukh,项目名称:ggit,代码行数:25,代码来源:pack.go

示例11: ObjectId

func (f *formatter) ObjectId(oid *objects.ObjectId) (int, error) {
	return fmt.Fprint(f.Writer, oid.String())
}
开发者ID:themihai,项目名称:ggit,代码行数:3,代码来源:object_ids.go

示例12: testObjectExpected

// testObjectExpected retrieves the commit with the given revision specification
// from the given repository and ensures that this operation went well and the
// returned object in fact has the expected oid.
func testObjectExpected(t *testing.T, repo Repository, rev string, expOid *objects.ObjectId, expType objects.ObjectType) {
	parent, err := ObjectFromRevision(repo, rev)
	util.AssertNoErr(t, err)
	util.Assert(t, parent.Header().Type() == expType)
	util.AssertEqualString(t, parent.ObjectId().String(), expOid.String())
}
开发者ID:jbrukh,项目名称:ggit,代码行数:9,代码来源:rev_parser_git_test.go

示例13: testZeros

func testZeros(t *testing.T, repo Repository, oid *objects.ObjectId) {
	rev := oid.String()
	testObjectExpected(t, repo, rev+"^0", oid, objects.ObjectCommit)
	testObjectExpected(t, repo, rev+"~0", oid, objects.ObjectCommit)
}
开发者ID:jbrukh,项目名称:ggit,代码行数:5,代码来源:rev_parser_git_test.go

示例14: objectFile

// objectFile turns an oid into a path relative to the
// git directory of a repository where that object should
// be located (if it is a loose object).
func objectFile(repo *DiskRepository, oid *objects.ObjectId) (file *os.File, err error) {
	hex := oid.String()
	path := path.Join(repo.path, DefaultObjectsDir, hex[0:2], hex[2:])
	return os.Open(path)
}
开发者ID:jbrukh,项目名称:ggit,代码行数:8,代码来源:disk_repository.go


注:本文中的github.com/jbrukh/ggit/api/objects.ObjectId类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。