@@ -8,7 +8,11 @@ import (
8
8
"path/filepath"
9
9
"testing"
10
10
11
+ "code.gitea.io/gitea/modules/setting"
12
+ "code.gitea.io/gitea/modules/test"
13
+
11
14
"github.com/stretchr/testify/assert"
15
+ "github.com/stretchr/testify/require"
12
16
)
13
17
14
18
func TestRepository_GetCommitBranches (t * testing.T ) {
@@ -126,3 +130,21 @@ func TestGetRefCommitID(t *testing.T) {
126
130
}
127
131
}
128
132
}
133
+
134
+ func TestCommitsByFileAndRange (t * testing.T ) {
135
+ defer test .MockVariableValue (& setting .Git .CommitsRangeSize , 2 )()
136
+
137
+ bareRepo1Path := filepath .Join (testReposDir , "repo1_bare" )
138
+ bareRepo1 , err := openRepositoryWithDefaultContext (bareRepo1Path )
139
+ require .NoError (t , err )
140
+ defer bareRepo1 .Close ()
141
+
142
+ // "foo" has 3 commits in "master" branch
143
+ commits , err := bareRepo1 .CommitsByFileAndRange (CommitsByFileAndRangeOptions {Revision : "master" , File : "foo" , Page : 1 })
144
+ require .NoError (t , err )
145
+ assert .Len (t , commits , 2 )
146
+
147
+ commits , err = bareRepo1 .CommitsByFileAndRange (CommitsByFileAndRangeOptions {Revision : "master" , File : "foo" , Page : 2 })
148
+ require .NoError (t , err )
149
+ assert .Len (t , commits , 1 )
150
+ }
0 commit comments