@@ -200,17 +200,21 @@ func (repo *Repository) GetCommitByPath(relpath string) (*Commit, error) {
200
200
return commits .Front ().Value .(* Commit ), nil
201
201
}
202
202
203
- var CommitsRangeSize = 50
204
-
205
- func (repo * Repository ) commitsByRange (id sha1 , page int ) (* list.List , error ) {
206
- stdout , err := NewCommand ("log" , id .String (), "--skip=" + strconv .Itoa ((page - 1 )* CommitsRangeSize ),
207
- "--max-count=" + strconv .Itoa (CommitsRangeSize ), _PRETTY_LOG_FORMAT ).RunInDirBytes (repo .Path )
203
+ func (repo * Repository ) CommitsByRangeSize (revision string , page , size int ) (* list.List , error ) {
204
+ stdout , err := NewCommand ("log" , revision , "--skip=" + strconv .Itoa ((page - 1 )* size ),
205
+ "--max-count=" + strconv .Itoa (size ), _PRETTY_LOG_FORMAT ).RunInDirBytes (repo .Path )
208
206
if err != nil {
209
207
return nil , err
210
208
}
211
209
return repo .parsePrettyFormatLogToList (stdout )
212
210
}
213
211
212
+ const DEFAULT_COMMITS_PAGE_SIZE = 50
213
+
214
+ func (repo * Repository ) CommitsByRange (revision string , page int ) (* list.List , error ) {
215
+ return repo .CommitsByRangeSize (revision , page , DEFAULT_COMMITS_PAGE_SIZE )
216
+ }
217
+
214
218
func (repo * Repository ) searchCommits (id sha1 , keyword string ) (* list.List , error ) {
215
219
stdout , err := NewCommand ("log" , id .String (), "-100" , "-i" , "--grep=" + keyword , _PRETTY_LOG_FORMAT ).RunInDirBytes (repo .Path )
216
220
if err != nil {
@@ -231,15 +235,19 @@ func (repo *Repository) FileCommitsCount(revision, file string) (int64, error) {
231
235
return commitsCount (repo .Path , revision , file )
232
236
}
233
237
234
- func (repo * Repository ) CommitsByFileAndRange (revision , file string , page int ) (* list.List , error ) {
235
- stdout , err := NewCommand ("log" , revision , "--skip=" + strconv .Itoa ((page - 1 )* 50 ),
236
- "--max-count=" + strconv .Itoa (CommitsRangeSize ), _PRETTY_LOG_FORMAT , "--" , file ).RunInDirBytes (repo .Path )
238
+ func (repo * Repository ) CommitsByFileAndRangeSize (revision , file string , page , size int ) (* list.List , error ) {
239
+ stdout , err := NewCommand ("log" , revision , "--skip=" + strconv .Itoa ((page - 1 )* size ),
240
+ "--max-count=" + strconv .Itoa (size ), _PRETTY_LOG_FORMAT , "--" , file ).RunInDirBytes (repo .Path )
237
241
if err != nil {
238
242
return nil , err
239
243
}
240
244
return repo .parsePrettyFormatLogToList (stdout )
241
245
}
242
246
247
+ func (repo * Repository ) CommitsByFileAndRange (revision , file string , page int ) (* list.List , error ) {
248
+ return repo .CommitsByFileAndRangeSize (revision , file , page , DEFAULT_COMMITS_PAGE_SIZE )
249
+ }
250
+
243
251
func (repo * Repository ) FilesCountBetween (startCommitID , endCommitID string ) (int , error ) {
244
252
stdout , err := NewCommand ("diff" , "--name-only" , startCommitID + "..." + endCommitID ).RunInDir (repo .Path )
245
253
if err != nil {
0 commit comments