MCPcopy
hub / github.com/go-git/go-git / TestLogFileForEach

Method TestLogFileForEach

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

Source from the content-addressed store, hash-verified

1994}
1995
1996func (s *RepositorySuite) TestLogFileForEach(c *C) {
1997 r, _ := Init(memory.NewStorage(), nil)
1998 err := r.clone(context.Background(), &CloneOptions{
1999 URL: s.GetBasicLocalRepositoryURL(),
2000 })
2001
2002 c.Assert(err, IsNil)
2003
2004 fileName := "php/crappy.php"
2005 cIter, err := r.Log(&LogOptions{FileName: &fileName})
2006 c.Assert(err, IsNil)
2007 defer cIter.Close()
2008
2009 commitOrder := []plumbing.Hash{
2010 plumbing.NewHash("918c48b83bd081e863dbe1b80f8998f058cd8294"),
2011 }
2012
2013 expectedIndex := 0
2014 err = cIter.ForEach(func(commit *object.Commit) error {
2015 expectedCommitHash := commitOrder[expectedIndex]
2016 c.Assert(commit.Hash.String(), Equals, expectedCommitHash.String())
2017 expectedIndex++
2018 return nil
2019 })
2020 c.Assert(err, IsNil)
2021 c.Assert(expectedIndex, Equals, 1)
2022}
2023
2024func (s *RepositorySuite) TestLogNonHeadFile(c *C) {
2025 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