@@ -205,22 +205,29 @@ func (repo *Repository) FileChangedBetweenCommits(filename, id1, id2 string) (bo
205205}
206206
207207// FileCommitsCount return the number of files at a revision
208- func (repo * Repository ) FileCommitsCount (revision , file string ) (int64 , error ) {
208+ func (repo * Repository ) FileCommitsCount (revision , file string , followRename ... bool ) (int64 , error ) {
209+ _followRename := false
210+ if len (followRename ) > 0 {
211+ _followRename = followRename [0 ]
212+ }
213+
209214 return CommitsCount (repo .Ctx ,
210215 CommitsCountOptions {
211- RepoPath : repo .Path ,
212- Revision : []string {revision },
213- RelPath : []string {file },
216+ RepoPath : repo .Path ,
217+ Revision : []string {revision },
218+ RelPath : []string {file },
219+ FollowRename : _followRename ,
214220 })
215221}
216222
217223type CommitsByFileAndRangeOptions struct {
218- Revision string
219- File string
220- Not string
221- Page int
222- Since string
223- Until string
224+ Revision string
225+ File string
226+ Not string
227+ Page int
228+ Since string
229+ Until string
230+ FollowRename bool
224231}
225232
226233// CommitsByFileAndRange return the commits according revision file and the page
@@ -233,10 +240,12 @@ func (repo *Repository) CommitsByFileAndRange(opts CommitsByFileAndRangeOptions)
233240 go func () {
234241 stderr := strings.Builder {}
235242 gitCmd := NewCommand (repo .Ctx , "--no-pager" , "log" ).
236- AddOptionFormat ("--follow" ).
237243 AddOptionFormat ("--pretty=format:%%H" ).
238244 AddOptionFormat ("--max-count=%d" , setting .Git .CommitsRangeSize ).
239245 AddOptionFormat ("--skip=%d" , (opts .Page - 1 )* setting .Git .CommitsRangeSize )
246+ if opts .FollowRename {
247+ gitCmd .AddOptionValues ("--follow" )
248+ }
240249 gitCmd .AddDynamicArguments (opts .Revision )
241250
242251 if opts .Not != "" {
0 commit comments