1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

Add last_committer_date and last_author_date for file contents API (#32921)

Fix #32886

Add `last_committer_date` and `last_author_date` in the content API
which is not implemented by Github API v3 at the moment.

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
Lunny Xiao
2025-04-02 21:47:31 -07:00
committed by GitHub
parent c27d87a9ac
commit 45c45934aa
11 changed files with 264 additions and 176 deletions

View File

@@ -188,6 +188,14 @@ func GetContents(ctx context.Context, repo *repo_model.Repository, treePath, ref
},
}
// GitHub doesn't have these fields in the response, but we could follow other similar APIs to name them
// https://docs.github.com/en/rest/commits/commits?apiVersion=2022-11-28#list-commits
if lastCommit.Committer != nil {
contentsResponse.LastCommitterDate = lastCommit.Committer.When
}
if lastCommit.Author != nil {
contentsResponse.LastAuthorDate = lastCommit.Author.When
}
// Now populate the rest of the ContentsResponse based on entry type
if entry.IsRegular() || entry.IsExecutable() {
contentsResponse.Type = string(ContentTypeRegular)