|
|
@ -53,7 +53,7 @@ func Releases(ctx *context.Context) { |
|
|
|
ctx.Data["Title"] = ctx.Tr("repo.release.releases") |
|
|
|
ctx.Data["Title"] = ctx.Tr("repo.release.releases") |
|
|
|
ctx.Data["PageIsReleaseList"] = true |
|
|
|
ctx.Data["PageIsReleaseList"] = true |
|
|
|
|
|
|
|
|
|
|
|
rawTags, err := ctx.Repo.GitRepo.GetTags() |
|
|
|
tagsResult, err := ctx.Repo.GitRepo.GetTagsAfter(ctx.Query("after"), 10) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
ctx.Handle(500, fmt.Sprintf("GetTags '%s'", ctx.Repo.Repository.RepoPath()), err) |
|
|
|
ctx.Handle(500, fmt.Sprintf("GetTags '%s'", ctx.Repo.Repository.RepoPath()), err) |
|
|
|
return |
|
|
|
return |
|
|
@ -68,13 +68,15 @@ func Releases(ctx *context.Context) { |
|
|
|
// Temproray cache commits count of used branches to speed up.
|
|
|
|
// Temproray cache commits count of used branches to speed up.
|
|
|
|
countCache := make(map[string]int64) |
|
|
|
countCache := make(map[string]int64) |
|
|
|
|
|
|
|
|
|
|
|
tags := make([]*models.Release, len(rawTags)) |
|
|
|
drafts := make([]*models.Release, 0, 1) |
|
|
|
for i, rawTag := range rawTags { |
|
|
|
tags := make([]*models.Release, len(tagsResult.Tags)) |
|
|
|
|
|
|
|
for i, rawTag := range tagsResult.Tags { |
|
|
|
for j, r := range releases { |
|
|
|
for j, r := range releases { |
|
|
|
if r == nil || (r.IsDraft && !ctx.Repo.IsOwner()) { |
|
|
|
if r == nil || (r.IsDraft && !ctx.Repo.IsOwner()) { |
|
|
|
continue |
|
|
|
continue |
|
|
|
} |
|
|
|
} |
|
|
|
if r.TagName == rawTag { |
|
|
|
releases[j] = nil // Mark as used.
|
|
|
|
|
|
|
|
|
|
|
|
r.Publisher, err = models.GetUserByID(r.PublisherID) |
|
|
|
r.Publisher, err = models.GetUserByID(r.PublisherID) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
if models.IsErrUserNotExist(err) { |
|
|
|
if models.IsErrUserNotExist(err) { |
|
|
@ -91,10 +93,14 @@ func Releases(ctx *context.Context) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
r.Note = markdown.RenderString(r.Note, ctx.Repo.RepoLink, ctx.Repo.Repository.ComposeMetas()) |
|
|
|
r.Note = markdown.RenderString(r.Note, ctx.Repo.RepoLink, ctx.Repo.Repository.ComposeMetas()) |
|
|
|
|
|
|
|
if r.TagName == rawTag { |
|
|
|
tags[i] = r |
|
|
|
tags[i] = r |
|
|
|
releases[j] = nil // Mark as used.
|
|
|
|
|
|
|
|
break |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if r.IsDraft { |
|
|
|
|
|
|
|
drafts = append(drafts, r) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if tags[i] == nil { |
|
|
|
if tags[i] == nil { |
|
|
@ -119,31 +125,18 @@ func Releases(ctx *context.Context) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for _, r := range releases { |
|
|
|
models.SortReleases(tags) |
|
|
|
if r == nil { |
|
|
|
if len(drafts) > 0 && tagsResult.HasLatest { |
|
|
|
continue |
|
|
|
tags = append(drafts, tags...) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
r.Publisher, err = models.GetUserByID(r.PublisherID) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
if models.IsErrUserNotExist(err) { |
|
|
|
|
|
|
|
r.Publisher = models.NewGhostUser() |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
ctx.Handle(500, "GetUserByID", err) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if err := calReleaseNumCommitsBehind(ctx.Repo, r, countCache); err != nil { |
|
|
|
|
|
|
|
ctx.Handle(500, "calReleaseNumCommitsBehind", err) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
r.Note = markdown.RenderString(r.Note, ctx.Repo.RepoLink, ctx.Repo.Repository.ComposeMetas()) |
|
|
|
|
|
|
|
tags = append(tags, r) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
models.SortReleases(tags) |
|
|
|
|
|
|
|
ctx.Data["Releases"] = tags |
|
|
|
ctx.Data["Releases"] = tags |
|
|
|
|
|
|
|
ctx.Data["HasPrevious"] = !tagsResult.HasLatest |
|
|
|
|
|
|
|
ctx.Data["ReachEnd"] = tagsResult.ReachEnd |
|
|
|
|
|
|
|
ctx.Data["PreviousAfter"] = tagsResult.PreviousAfter |
|
|
|
|
|
|
|
if len(tags) > 0 { |
|
|
|
|
|
|
|
ctx.Data["NextAfter"] = tags[len(tags)-1].TagName |
|
|
|
|
|
|
|
} |
|
|
|
ctx.HTML(200, RELEASES) |
|
|
|
ctx.HTML(200, RELEASES) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|