From adebf1cd114d8c5f9a9f13b3a9304d95bf08ef94 Mon Sep 17 00:00:00 2001 From: Gusted Date: Sun, 1 May 2022 15:48:52 +0800 Subject: [PATCH] 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 Reviewed-by: 6543 <6543@obermui.de> Co-authored-by: Gusted Co-committed-by: Gusted --- gitea/repo_commit.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gitea/repo_commit.go b/gitea/repo_commit.go index cf53ede..72bb28c 100644 --- a/gitea/repo_commit.go +++ b/gitea/repo_commit.go @@ -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() }