Template
1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo synced 2024-11-24 10:46:10 +01:00
This commit is contained in:
Unknown 2014-06-12 09:10:39 -04:00
parent 1161c71ac1
commit 9961f9a53c
4 changed files with 22 additions and 9 deletions

View file

@ -9,7 +9,7 @@ import (
"strings"
"time"
"github.com/Unknwon/com"
// "github.com/Unknwon/com"
"github.com/gogits/git"
)
@ -26,7 +26,8 @@ type Release struct {
Title string
TagName string
LowerTagName string
SHA1 string
Target string
Sha1 string `xorm:"VARCHAR(40)"`
NumCommits int
NumCommitsBehind int `xorm:"-"`
Note string `xorm:"TEXT"`
@ -59,9 +60,13 @@ func CreateRelease(gitRepo *git.Repository, rel *Release) error {
}
if !gitRepo.IsTagExist(rel.TagName) {
_, stderr, err := com.ExecCmdDir(gitRepo.Path, "git", "tag", rel.TagName, "-m", rel.Title)
commit, err := gitRepo.GetCommitOfBranch(rel.Target)
if err != nil {
return errors.New(stderr)
return err
}
if err = gitRepo.CreateTag(rel.TagName, commit.Id.String()); err != nil {
return err
}
} else {
commit, err := gitRepo.GetCommitOfTag(rel.TagName)

View file

@ -205,6 +205,7 @@ func (f *CreateLabelForm) Validate(errors *binding.Errors, req *http.Request, co
type NewReleaseForm struct {
TagName string `form:"tag_name" binding:"Required"`
Target string `form:"tag_target" binding:"Required"`
Title string `form:"title" binding:"Required"`
Content string `form:"content" binding:"Required"`
Prerelease bool `form:"prerelease"`
@ -213,6 +214,7 @@ type NewReleaseForm struct {
func (f *NewReleaseForm) Name(field string) string {
names := map[string]string{
"TagName": "Tag name",
"Target": "Target",
"Title": "Release title",
"Content": "Release content",
}

View file

@ -79,7 +79,7 @@ func Releases(ctx *middleware.Context) {
tags.rels[i] = &models.Release{
Title: rawTag,
TagName: rawTag,
SHA1: commit.Id.String(),
Sha1: commit.Id.String(),
}
tags.rels[i].NumCommits, err = ctx.Repo.GitRepo.CommitsCount(commit.Id.String())
if err != nil {
@ -129,12 +129,18 @@ func ReleasesNewPost(ctx *middleware.Context, form auth.NewReleaseForm) {
return
}
if !ctx.Repo.GitRepo.IsBranchExist(form.Target) {
ctx.RenderWithErr("Target branch does not exist", "release/new", &form)
return
}
rel := &models.Release{
RepoId: ctx.Repo.Repository.Id,
PublisherId: ctx.User.Id,
Title: form.Title,
TagName: form.TagName,
SHA1: ctx.Repo.Commit.Id.String(),
Target: form.Target,
Sha1: ctx.Repo.Commit.Id.String(),
NumCommits: commitsCount,
Note: form.Content,
IsPrerelease: form.Prerelease,

View file

@ -11,12 +11,12 @@
</h4>
<ul id="release-list" class="list-unstyled">
{{range .Releases}}
<li class="release-item clearfix" id="release-{{.SHA1}}">
<li class="release-item clearfix" id="release-{{.Sha1}}">
{{if .PublisherId}}
<div class="col-md-2 text-right">
{{if .IsPrerelease}}<span class="btn btn-warning status pre-release">Pre-Release</span>{{else}}<span class="btn btn-success status stable">Stable</span>{{end}}
<a class="tag" href="{{$.RepoLink}}/src/{{.TagName}}" rel="nofollow"><i class="fa fa-tag"></i>{{.TagName}}</a>
<a class="commit" href="{{$.RepoLink}}/src/{{.SHA1}}" rel="nofollow"><i class="fa fa-code"></i>{{ShortSha .SHA1}}</a>
<a class="commit" href="{{$.RepoLink}}/src/{{.Sha1}}" rel="nofollow"><i class="fa fa-code"></i>{{ShortSha .Sha1}}</a>
</div>
<div class="col-md-10">
<h4 class="title"><a href="{{$.RepoLink}}/src/{{.TagName}}">{{.Title}}</a></h4>
@ -37,7 +37,7 @@
</div>
{{else}}
<div class="col-md-2 text-right">
<a class="commit" href="{{$.RepoLink}}/src/{{.SHA1}}" rel="nofollow"><i class="fa fa-code"></i>{{ShortSha .SHA1}}</a>
<a class="commit" href="{{$.RepoLink}}/src/{{.Sha1}}" rel="nofollow"><i class="fa fa-code"></i>{{ShortSha .Sha1}}</a>
</div>
<div class="col-md-10">
<h5 class="title"><a href="{{$.RepoLink}}/src/{{.TagName}}" rel="nofollow">{{.TagName}}</a><i class="fa fa-tag"></i></h5>