Skip to content

Commit 6f5bc59

Browse files
committed
Add last commit when for contents API
1 parent 5ec8df0 commit 6f5bc59

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

modules/structs/repo_file.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
package structs
66

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

services/repository/files/content.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,12 +178,13 @@ func GetContents(ctx context.Context, repo *repo_model.Repository, treePath, ref
178178

179179
// All content types have these fields in populated
180180
contentsResponse := &api.ContentsResponse{
181-
Name: entry.Name(),
182-
Path: treePath,
183-
SHA: entry.ID.String(),
184-
LastCommitSHA: lastCommit.ID.String(),
185-
Size: entry.Size(),
186-
URL: &selfURLString,
181+
Name: entry.Name(),
182+
Path: treePath,
183+
SHA: entry.ID.String(),
184+
LastCommitSHA: lastCommit.ID.String(),
185+
LastCommitWhen: lastCommit.Committer.When,
186+
Size: entry.Size(),
187+
URL: &selfURLString,
187188
Links: &api.FileLinksResponse{
188189
Self: &selfURLString,
189190
},

templates/swagger/v1_json.tmpl

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)