summaryrefslogtreecommitdiffstats
path: root/routers/api/v1/repo
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2019-12-24 03:33:52 +0100
committerLunny Xiao <xiaolunwen@gmail.com>2019-12-24 10:33:52 +0800
commit40e99ea010b3b0be241be0e1365a70d33777bcf2 (patch)
treecc7930e51a8ed41fcb183dae075d7ab211d06834 /routers/api/v1/repo
parent017f314b5a0f930b477efa1c2a5309f8cdd6d3c3 (diff)
downloadgitea-40e99ea010b3b0be241be0e1365a70d33777bcf2.tar.gz
gitea-40e99ea010b3b0be241be0e1365a70d33777bcf2.zip
[API] Extend contents with dates (#9464)
* extend CommitTree func * make sure Date NOT nil * spell corection Co-Authored-By: zeripath <art27@cantab.net> * add TEST Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'routers/api/v1/repo')
-rw-r--r--routers/api/v1/repo/file.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/routers/api/v1/repo/file.go b/routers/api/v1/repo/file.go
index 8cfe039df5..14923984bd 100644
--- a/routers/api/v1/repo/file.go
+++ b/routers/api/v1/repo/file.go
@@ -8,6 +8,7 @@ package repo
import (
"encoding/base64"
"net/http"
+ "time"
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/context"
@@ -213,6 +214,16 @@ func CreateFile(ctx *context.APIContext, apiOpts api.CreateFileOptions) {
Name: apiOpts.Author.Name,
Email: apiOpts.Author.Email,
},
+ Dates: &repofiles.CommitDateOptions{
+ Author: apiOpts.Dates.Author,
+ Committer: apiOpts.Dates.Committer,
+ },
+ }
+ if opts.Dates.Author.IsZero() {
+ opts.Dates.Author = time.Now()
+ }
+ if opts.Dates.Committer.IsZero() {
+ opts.Dates.Committer = time.Now()
}
if opts.Message == "" {
@@ -277,6 +288,16 @@ func UpdateFile(ctx *context.APIContext, apiOpts api.UpdateFileOptions) {
Name: apiOpts.Author.Name,
Email: apiOpts.Author.Email,
},
+ Dates: &repofiles.CommitDateOptions{
+ Author: apiOpts.Dates.Author,
+ Committer: apiOpts.Dates.Committer,
+ },
+ }
+ if opts.Dates.Author.IsZero() {
+ opts.Dates.Author = time.Now()
+ }
+ if opts.Dates.Committer.IsZero() {
+ opts.Dates.Committer = time.Now()
}
if opts.Message == "" {
@@ -364,6 +385,16 @@ func DeleteFile(ctx *context.APIContext, apiOpts api.DeleteFileOptions) {
Name: apiOpts.Author.Name,
Email: apiOpts.Author.Email,
},
+ Dates: &repofiles.CommitDateOptions{
+ Author: apiOpts.Dates.Author,
+ Committer: apiOpts.Dates.Committer,
+ },
+ }
+ if opts.Dates.Author.IsZero() {
+ opts.Dates.Author = time.Now()
+ }
+ if opts.Dates.Committer.IsZero() {
+ opts.Dates.Committer = time.Now()
}
if opts.Message == "" {