diff options
author | Saeed Rasooli <saeed.gnu@gmail.com> | 2019-11-29 14:43:56 +0330 |
---|---|---|
committer | Saeed Rasooli <saeed.gnu@gmail.com> | 2019-11-29 16:46:45 +0330 |
commit | e0378b2c67fffba7aa98f1fb4355bc1bc58b215b (patch) | |
tree | f256e2e30be2cde92d141e9e9be29b7dda13a5ee | |
parent | 224f047f4f95b44434f84303746c37439929e02b (diff) | |
download | go-git-e0378b2c67fffba7aa98f1fb4355bc1bc58b215b.tar.gz |
repository_test.go: add TestLogPathFilterRegexp
Signed-off-by: Saeed Rasooli <saeed.gnu@gmail.com>
-rw-r--r-- | repository_test.go | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/repository_test.go b/repository_test.go index 2bca078..65c1423 100644 --- a/repository_test.go +++ b/repository_test.go @@ -1694,6 +1694,42 @@ func (s *RepositorySuite) TestLogPathRegexpWithError(c *C) { c.Assert(err, NotNil) } +func (s *RepositorySuite) TestLogPathFilterRegexp(c *C) { + pathRE := regexp.MustCompile(".*\\.go") + pathIter := func(path string) bool { + return pathRE.MatchString(path) + } + + r, _ := Init(memory.NewStorage(), nil) + err := r.clone(context.Background(), &CloneOptions{ + URL: s.GetBasicLocalRepositoryURL(), + }) + c.Assert(err, IsNil) + + expectedCommitIDs := []string{ + "6ecf0ef2c2dffb796033e5a02219af86ec6584e5", + "918c48b83bd081e863dbe1b80f8998f058cd8294", + } + commitIDs := []string{} + + cIter, err := r.Log(&LogOptions{ + PathFilter: pathIter, + From: plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5"), + }) + c.Assert(err, IsNil) + defer cIter.Close() + + cIter.ForEach(func(commit *object.Commit) error { + commitIDs = append(commitIDs, commit.ID().String()) + return nil + }) + c.Assert( + strings.Join(commitIDs, ", "), + Equals, + strings.Join(expectedCommitIDs, ", "), + ) +} + func (s *RepositorySuite) TestLogLimitNext(c *C) { r, _ := Init(memory.NewStorage(), nil) err := r.clone(context.Background(), &CloneOptions{ |