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


Golang core.NewHash函数代码示例

本文整理汇总了Golang中gopkg/in/src-d/go-git/v2/core.NewHash函数的典型用法代码示例。如果您正苦于以下问题:Golang NewHash函数的具体用法?Golang NewHash怎么用?Golang NewHash使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: TestRevList

func (s *ReferencesSuite) TestRevList(c *C) {
	for _, t := range referencesTests {
		repo, ok := s.repos[t.repo]
		c.Assert(ok, Equals, true)

		commit, err := repo.Commit(core.NewHash(t.commit))
		c.Assert(err, IsNil)

		revs, err := commit.References(t.path)
		c.Assert(err, IsNil)
		c.Assert(len(revs), Equals, len(t.revs))

		for i := range revs {
			if revs[i].Hash.String() != t.revs[i] {
				commit, err := repo.Commit(core.NewHash(t.revs[i]))
				c.Assert(err, IsNil)
				equiv, err := equivalent(t.path, revs[i], commit)
				c.Assert(err, IsNil)
				if equiv {
					fmt.Printf("cherry-pick detected: %s    %s\n", revs[i].Hash.String(), t.revs[i])
				} else {
					c.Fatalf("\nrepo=%s, commit=%s, path=%s, \n%s",
						t.repo, t.commit, t.path, compareSideBySide(t.revs, revs))
				}
			}
		}
	}
}
开发者ID:scjalliance,项目名称:go-git,代码行数:28,代码来源:references_test.go

示例2: mockBlame

func (s *BlameCommon) mockBlame(t blameTest, c *C) (blame *Blame) {
	repo, ok := s.repos[t.repo]
	c.Assert(ok, Equals, true)

	commit, err := repo.Commit(core.NewHash(t.rev))
	c.Assert(err, IsNil, Commentf("%v: repo=%s, rev=%s", err, repo, t.rev))

	file, err := commit.File(t.path)
	c.Assert(err, IsNil)
	lines := file.Lines()
	c.Assert(len(t.blames), Equals, len(lines), Commentf(
		"repo=%s, path=%s, rev=%s: the number of lines in the file and the number of expected blames differ (len(blames)=%d, len(lines)=%d)\nblames=%#q\nlines=%#q", t.repo, t.path, t.rev, len(t.blames), len(lines), t.blames, lines))

	blamedLines := make([]*line, 0, len(t.blames))
	for i := range t.blames {
		commit, err := repo.Commit(core.NewHash(t.blames[i]))
		c.Assert(err, IsNil)
		l := &line{
			author: commit.Author.Email,
			text:   lines[i],
		}
		blamedLines = append(blamedLines, l)
	}

	return &Blame{
		Path:  t.path,
		Rev:   core.NewHash(t.rev),
		Lines: blamedLines,
	}
}
开发者ID:scjalliance,项目名称:go-git,代码行数:30,代码来源:blame_test.go

示例3: TestGitUploadPackRequest

func (s *SuiteCommon) TestGitUploadPackRequest(c *C) {
	r := &GitUploadPackRequest{}
	r.Want(core.NewHash("d82f291cde9987322c8a0c81a325e1ba6159684c"))
	r.Want(core.NewHash("2b41ef280fdb67a9b250678686a0c3e03b0a9989"))
	r.Have(core.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5"))

	c.Assert(r.String(), Equals,
		"0032want d82f291cde9987322c8a0c81a325e1ba6159684c\n"+
			"0032want 2b41ef280fdb67a9b250678686a0c3e03b0a9989\n"+
			"0032have 6ecf0ef2c2dffb796033e5a02219af86ec6584e5\n0000"+
			"0009done\n",
	)
}
开发者ID:scjalliance,项目名称:go-git,代码行数:13,代码来源:common_test.go

示例4: makeHashSlice

func makeHashSlice(hashes []string) []core.Hash {
	series := make([]core.Hash, 0, len(hashes))
	for _, member := range hashes {
		series = append(series, core.NewHash(member))
	}
	return series
}
开发者ID:bestwpw,项目名称:go-git,代码行数:7,代码来源:commit_test.go

示例5: TestFetchNotConnected

func (s *SuiteRemote) TestFetchNotConnected(c *C) {
	r := NewGitUploadPackService("foo bar")
	pr := &common.GitUploadPackRequest{}
	pr.Want(core.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5"))
	_, err := r.Fetch(pr)
	c.Assert(err, Equals, ErrNotConnected)
}
开发者ID:scjalliance,项目名称:go-git,代码行数:7,代码来源:git_upload_pack_test.go

示例6: AssertObjects

func AssertObjects(c *C, s *core.RAWObjectStorage, expects []string) {
	c.Assert(len(expects), Equals, len(s.Objects))
	for _, expected := range expects {
		obtained, ok := s.Get(core.NewHash(expected))
		c.Assert(ok, Equals, true)
		c.Assert(obtained.Hash().String(), Equals, expected)
	}
}
开发者ID:scjalliance,项目名称:go-git,代码行数:8,代码来源:reader_test.go

示例7: readLine

func (r *GitUploadPackInfo) readLine(line string) {
	parts := strings.Split(strings.Trim(line, " \n"), " ")
	if len(parts) != 2 {
		return
	}

	r.Refs[parts[1]] = core.NewHash(parts[0])
}
开发者ID:scjalliance,项目名称:go-git,代码行数:8,代码来源:common.go

示例8: Ref

// Ref returns the Hash pointing the given refName
func (r *Remote) Ref(refName string) (core.Hash, error) {
	ref, ok := r.upInfo.Refs[refName]
	if !ok {
		return core.NewHash(""), fmt.Errorf("unable to find ref %q", refName)
	}

	return ref, nil
}
开发者ID:scjalliance,项目名称:go-git,代码行数:9,代码来源:remote.go

示例9: makeObjectSlice

func makeObjectSlice(hashes []string, storage core.ObjectStorage) []core.Object {
	series := make([]core.Object, 0, len(hashes))
	for _, member := range hashes {
		obj, err := storage.Get(core.NewHash(member))
		if err == nil {
			series = append(series, obj)
		}
	}
	return series
}
开发者ID:bestwpw,项目名称:go-git,代码行数:10,代码来源:commit_test.go

示例10: TestContents

func (s *SuiteFile) TestContents(c *C) {
	for i, t := range contentsTests {
		commit, err := s.repos[t.repo].Commit(core.NewHash(t.commit))
		c.Assert(err, IsNil, Commentf("subtest %d: %v (%s)", i, err, t.commit))

		file, err := commit.File(t.path)
		c.Assert(err, IsNil)
		c.Assert(file.Contents(), Equals, t.contents, Commentf(
			"subtest %d: commit=%s, path=%s", i, t.commit, t.path))
	}
}
开发者ID:scjalliance,项目名称:go-git,代码行数:11,代码来源:file_test.go

示例11: commits

// returns the commits from a slice of hashes
func (s *ReferencesSuite) commits(cc *C, repo string, hs ...string) []*Commit {
	r, ok := s.repos[repo]
	cc.Assert(ok, Equals, true)
	result := make([]*Commit, 0, len(hs))
	for _, h := range hs {
		c, err := r.Commit(core.NewHash(h))
		cc.Assert(err, IsNil)
		result = append(result, c)
	}
	return result
}
开发者ID:scjalliance,项目名称:go-git,代码行数:12,代码来源:references_test.go

示例12: TestIgnoreEmptyDirEntries

// It is difficult to assert that we are ignoring an (empty) dir as even
// if we don't, no files will be found in it.
//
// At least this test has a high chance of panicking if
// we don't ignore empty dirs.
func (s *SuiteFile) TestIgnoreEmptyDirEntries(c *C) {
	for i, t := range ignoreEmptyDirEntriesTests {
		commit, err := s.repos[t.repo].Commit(core.NewHash(t.commit))
		c.Assert(err, IsNil, Commentf("subtest %d: %v (%s)", i, err, t.commit))

		for file := range commit.Tree().Files() {
			_ = file.Contents()
			// this would probably panic if we are not ignoring empty dirs
		}
	}
}
开发者ID:scjalliance,项目名称:go-git,代码行数:16,代码来源:file_test.go

示例13: Info

func (s *MockGitUploadPackService) Info() (*common.GitUploadPackInfo, error) {
	hash := core.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")

	cap := common.NewCapabilities()
	cap.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")

	return &common.GitUploadPackInfo{
		Capabilities: cap,
		Head:         hash,
		Refs:         map[string]core.Hash{"refs/heads/master": hash},
	}, nil
}
开发者ID:scjalliance,项目名称:go-git,代码行数:12,代码来源:common_test.go

示例14: TestFile

func (s *SuiteCommit) TestFile(c *C) {
	for i, t := range fileTests {
		commit, err := s.repos[t.repo].Commit(core.NewHash(t.commit))
		c.Assert(err, IsNil, Commentf("subtest %d: %v (%s)", i, err, t.commit))

		file, err := commit.File(t.path)
		found := err == nil
		c.Assert(found, Equals, t.found, Commentf("subtest %d, path=%s, commit=%s", i, t.path, t.commit))
		if found {
			c.Assert(file.Hash.String(), Equals, t.blobHash, Commentf("subtest %d, commit=%s, path=%s", i, t.commit, t.path))
		}
	}
}
开发者ID:scjalliance,项目名称:go-git,代码行数:13,代码来源:commit_test.go

示例15: Decode

// Decode transform an core.Object into a Blob struct
func (c *Commit) Decode(o core.Object) error {
	c.Hash = o.Hash()
	r := bufio.NewReader(o.Reader())

	var message bool
	for {
		line, err := r.ReadSlice('\n')
		if err != nil && err != io.EOF {
			return err
		}

		line = bytes.TrimSpace(line)
		if !message {
			if len(line) == 0 {
				message = true
				continue
			}

			split := bytes.SplitN(line, []byte{' '}, 2)
			switch string(split[0]) {
			case "tree":
				c.tree = core.NewHash(string(split[1]))
			case "parent":
				c.parents = append(c.parents, core.NewHash(string(split[1])))
			case "author":
				c.Author.Decode(split[1])
			case "committer":
				c.Committer.Decode(split[1])
			}
		} else {
			c.Message += string(line) + "\n"
		}

		if err == io.EOF {
			return nil
		}
	}
}
开发者ID:scjalliance,项目名称:go-git,代码行数:39,代码来源:commit.go


注:本文中的gopkg/in/src-d/go-git/v2/core.NewHash函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。