MCPcopy Create free account
hub / github.com/go-git/go-git / TestLogFileForEach

Method TestLogFileForEach

repository_test.go:2028–2054  ·  view source on GitHub ↗
(c *C)

Source from the content-addressed store, hash-verified

2026}
2027
2028func (s *RepositorySuite) TestLogFileForEach(c *C) {
2029 r, _ := Init(memory.NewStorage(), nil)
2030 err := r.clone(context.Background(), &CloneOptions{
2031 URL: s.GetBasicLocalRepositoryURL(),
2032 })
2033
2034 c.Assert(err, IsNil)
2035
2036 fileName := "php/crappy.php"
2037 cIter, err := r.Log(&LogOptions{FileName: &fileName})
2038 c.Assert(err, IsNil)
2039 defer cIter.Close()
2040
2041 commitOrder := []plumbing.Hash{
2042 plumbing.NewHash("918c48b83bd081e863dbe1b80f8998f058cd8294"),
2043 }
2044
2045 expectedIndex := 0
2046 err = cIter.ForEach(func(commit *object.Commit) error {
2047 expectedCommitHash := commitOrder[expectedIndex]
2048 c.Assert(commit.Hash.String(), Equals, expectedCommitHash.String())
2049 expectedIndex++
2050 return nil
2051 })
2052 c.Assert(err, IsNil)
2053 c.Assert(expectedIndex, Equals, 1)
2054}
2055
2056func (s *RepositorySuite) TestLogNonHeadFile(c *C) {
2057 r, _ := Init(memory.NewStorage(), nil)

Callers

nothing calls this directly

Calls 9

NewStorageFunction · 0.92
NewHashFunction · 0.92
InitFunction · 0.85
cloneMethod · 0.80
LogMethod · 0.80
CloseMethod · 0.65
ForEachMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected