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

Method TestLogFileInitialCommit

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

Source from the content-addressed store, hash-verified

2117}
2118
2119func (s *RepositorySuite) TestLogFileInitialCommit(c *C) {
2120 r, _ := Init(memory.NewStorage(), nil)
2121 err := r.clone(context.Background(), &CloneOptions{
2122 URL: s.GetBasicLocalRepositoryURL(),
2123 })
2124 c.Assert(err, IsNil)
2125
2126 fileName := "LICENSE"
2127 cIter, err := r.Log(&LogOptions{
2128 Order: LogOrderCommitterTime,
2129 FileName: &fileName,
2130 })
2131 c.Assert(err, IsNil)
2132 defer cIter.Close()
2133
2134 commitOrder := []plumbing.Hash{
2135 plumbing.NewHash("b029517f6300c2da0f4b651b8642506cd6aaf45d"),
2136 }
2137
2138 expectedIndex := 0
2139 err = cIter.ForEach(func(commit *object.Commit) error {
2140 expectedCommitHash := commitOrder[expectedIndex]
2141 c.Assert(commit.Hash.String(), Equals, expectedCommitHash.String())
2142 expectedIndex++
2143 return nil
2144 })
2145 c.Assert(err, IsNil)
2146 c.Assert(expectedIndex, Equals, 1)
2147}
2148
2149func (s *RepositorySuite) TestLogFileWithOtherParamsFail(c *C) {
2150 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