1
1
mirror of https://github.com/go-gitea/gitea synced 2025-01-27 01:54:34 +00:00

Add last commit when for contents API

This commit is contained in:
Lunny Xiao 2024-12-19 15:53:34 -08:00
parent 5ec8df02f6
commit 6f5bc5923e
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
3 changed files with 16 additions and 6 deletions

View File

@ -4,6 +4,8 @@
package structs
import "time"
// FileOptions options for all file APIs
type FileOptions struct {
// message (optional) for the commit of this file. if not supplied, a default message will be used
@ -121,6 +123,8 @@ type ContentsResponse struct {
Path string `json:"path"`
SHA string `json:"sha"`
LastCommitSHA string `json:"last_commit_sha"`
// swagger:strfmt date-time
LastCommitWhen time.Time `json:"last_commit_when"`
// `type` will be `file`, `dir`, `symlink`, or `submodule`
Type string `json:"type"`
Size int64 `json:"size"`

View File

@ -178,12 +178,13 @@ func GetContents(ctx context.Context, repo *repo_model.Repository, treePath, ref
// All content types have these fields in populated
contentsResponse := &api.ContentsResponse{
Name: entry.Name(),
Path: treePath,
SHA: entry.ID.String(),
LastCommitSHA: lastCommit.ID.String(),
Size: entry.Size(),
URL: &selfURLString,
Name: entry.Name(),
Path: treePath,
SHA: entry.ID.String(),
LastCommitSHA: lastCommit.ID.String(),
LastCommitWhen: lastCommit.Committer.When,
Size: entry.Size(),
URL: &selfURLString,
Links: &api.FileLinksResponse{
Self: &selfURLString,
},

View File

@ -19515,6 +19515,11 @@
"type": "string",
"x-go-name": "LastCommitSHA"
},
"last_commit_when": {
"type": "string",
"format": "date-time",
"x-go-name": "LastCommitWhen"
},
"name": {
"type": "string",
"x-go-name": "Name"