Add file commit history (#588)

- Allow to specify to only get commit history of specific file.
- Ref: https://github.com/go-gitea/gitea/pull/17652

Reviewed-on: https://gitea.com/gitea/go-sdk/pulls/588
Reviewed-by: John Olheiser <john.olheiser@gmail.com>
Reviewed-by: 6543 <6543@obermui.de>
Co-authored-by: Gusted <williamzijl7@hotmail.com>
Co-committed-by: Gusted <williamzijl7@hotmail.com>
This commit is contained in:
Gusted 2022-05-01 15:48:52 +08:00 committed by 6543
parent 8fab37e740
commit adebf1cd11
1 changed files with 6 additions and 1 deletions

View File

@ -85,14 +85,19 @@ type ListCommitOptions struct {
ListOptions
// SHA or branch to start listing commits from (usually 'master')
SHA string
// Path indicates that only commits that include the path's file/dir should be returned.
Path string
}
// QueryEncode turns options into querystring argument
func (opt *ListCommitOptions) QueryEncode() string {
query := opt.ListOptions.getURLQuery()
query := opt.getURLQuery()
if opt.SHA != "" {
query.Add("sha", opt.SHA)
}
if opt.Path != "" {
query.Add("path", opt.Path)
}
return query.Encode()
}