@@ -264,14 +264,15 @@ func (repo *Repository) FilesCountBetween(startCommitID, endCommitID string) (in
264
264
return len (strings .Split (stdout , "\n " )) - 1 , nil
265
265
}
266
266
267
- // CommitsBetween returns a list that contains commits between [last, before).
267
+ // CommitsBetween returns a list that contains commits between [before, last).
268
+ // If before is detached (removed by reset + push) it is not included.
268
269
func (repo * Repository ) CommitsBetween (last * Commit , before * Commit ) (* list.List , error ) {
269
270
var stdout []byte
270
271
var err error
271
272
if before == nil {
272
273
stdout , err = NewCommand ("rev-list" , last .ID .String ()).RunInDirBytes (repo .Path )
273
274
} else {
274
- stdout , err = NewCommand ("rev-list" , before .ID .String ()+ "... " + last .ID .String ()).RunInDirBytes (repo .Path )
275
+ stdout , err = NewCommand ("rev-list" , before .ID .String ()+ ".." + last .ID .String ()).RunInDirBytes (repo .Path )
275
276
if err != nil && strings .Contains (err .Error (), "no merge base" ) {
276
277
// future versions of git >= 2.28 are likely to return an error if before and last have become unrelated.
277
278
// previously it would return the results of git rev-list before last so let's try that...
@@ -284,14 +285,14 @@ func (repo *Repository) CommitsBetween(last *Commit, before *Commit) (*list.List
284
285
return repo .parsePrettyFormatLogToList (bytes .TrimSpace (stdout ))
285
286
}
286
287
287
- // CommitsBetweenLimit returns a list that contains at most limit commits skipping the first skip commits between [last, before )
288
+ // CommitsBetweenLimit returns a list that contains at most limit commits skipping the first skip commits between [before, last )
288
289
func (repo * Repository ) CommitsBetweenLimit (last * Commit , before * Commit , limit , skip int ) (* list.List , error ) {
289
290
var stdout []byte
290
291
var err error
291
292
if before == nil {
292
293
stdout , err = NewCommand ("rev-list" , "--max-count" , strconv .Itoa (limit ), "--skip" , strconv .Itoa (skip ), last .ID .String ()).RunInDirBytes (repo .Path )
293
294
} else {
294
- stdout , err = NewCommand ("rev-list" , "--max-count" , strconv .Itoa (limit ), "--skip" , strconv .Itoa (skip ), before .ID .String ()+ "... " + last .ID .String ()).RunInDirBytes (repo .Path )
295
+ stdout , err = NewCommand ("rev-list" , "--max-count" , strconv .Itoa (limit ), "--skip" , strconv .Itoa (skip ), before .ID .String ()+ ".." + last .ID .String ()).RunInDirBytes (repo .Path )
295
296
if err != nil && strings .Contains (err .Error (), "no merge base" ) {
296
297
// future versions of git >= 2.28 are likely to return an error if before and last have become unrelated.
297
298
// previously it would return the results of git rev-list --max-count n before last so let's try that...
@@ -322,7 +323,7 @@ func (repo *Repository) CommitsBetweenIDs(last, before string) (*list.List, erro
322
323
323
324
// CommitsCountBetween return numbers of commits between two commits
324
325
func (repo * Repository ) CommitsCountBetween (start , end string ) (int64 , error ) {
325
- count , err := CommitsCountFiles (repo .Path , []string {start + "... " + end }, []string {})
326
+ count , err := CommitsCountFiles (repo .Path , []string {start + ".." + end }, []string {})
326
327
if err != nil && strings .Contains (err .Error (), "no merge base" ) {
327
328
// future versions of git >= 2.28 are likely to return an error if before and last have become unrelated.
328
329
// previously it would return the results of git rev-list before last so let's try that...
0 commit comments