mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-25 08:59:31 -05:00
* Fix #3315: Release dont use tag creation date * Simplify code and apply gofmt * remove useless block (ctx.Repo.GitRepo.GetTag) on EditReleasePost * apply gofmt on modified files
This commit is contained in:
parent
ab9c5fb5e7
commit
30fda0f1ae
2 changed files with 13 additions and 1 deletions
|
@ -39,7 +39,9 @@ type Release struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Release) BeforeInsert() {
|
func (r *Release) BeforeInsert() {
|
||||||
r.CreatedUnix = time.Now().Unix()
|
if r.CreatedUnix == 0 {
|
||||||
|
r.CreatedUnix = time.Now().Unix()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Release) AfterSet(colName string, _ xorm.Cell) {
|
func (r *Release) AfterSet(colName string, _ xorm.Cell) {
|
||||||
|
|
|
@ -167,6 +167,15 @@ func NewReleasePost(ctx *context.Context, form auth.NewReleaseForm) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var tagCreatedUnix int64
|
||||||
|
tag, err := ctx.Repo.GitRepo.GetTag(form.TagName)
|
||||||
|
if err == nil {
|
||||||
|
commit, err := tag.Commit()
|
||||||
|
if err == nil {
|
||||||
|
tagCreatedUnix = commit.Author.When.Unix()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
commit, err := ctx.Repo.GitRepo.GetBranchCommit(form.Target)
|
commit, err := ctx.Repo.GitRepo.GetBranchCommit(form.Target)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Handle(500, "GetBranchCommit", err)
|
ctx.Handle(500, "GetBranchCommit", err)
|
||||||
|
@ -190,6 +199,7 @@ func NewReleasePost(ctx *context.Context, form auth.NewReleaseForm) {
|
||||||
Note: form.Content,
|
Note: form.Content,
|
||||||
IsDraft: len(form.Draft) > 0,
|
IsDraft: len(form.Draft) > 0,
|
||||||
IsPrerelease: form.Prerelease,
|
IsPrerelease: form.Prerelease,
|
||||||
|
CreatedUnix: tagCreatedUnix,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = models.CreateRelease(ctx.Repo.GitRepo, rel); err != nil {
|
if err = models.CreateRelease(ctx.Repo.GitRepo, rel); err != nil {
|
||||||
|
|
Loading…
Reference in a new issue