aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--repository_test.go36
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{