aboutsummaryrefslogtreecommitdiffstats
path: root/routers/repo
diff options
context:
space:
mode:
authora1012112796 <1012112796@qq.com>2021-03-01 03:57:45 +0800
committerGitHub <noreply@github.com>2021-02-28 19:57:45 +0000
commit83cf1a894e5a3a60ea72fa6b92744cb0705dd145 (patch)
tree516863d9c6ead4020004d1730d6bb2d91afbf56b /routers/repo
parent3e652860bb66fafe162079553f8640553c18fe79 (diff)
downloadgitea-83cf1a894e5a3a60ea72fa6b92744cb0705dd145.tar.gz
gitea-83cf1a894e5a3a60ea72fa6b92744cb0705dd145.zip
Create tag on ui (#13467)
Support create single tag directly support create tag with message from create release ui Signed-off-by: a1012112796 <1012112796@qq.com> Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: zeripath <art27@cantab.net>
Diffstat (limited to 'routers/repo')
-rw-r--r--routers/repo/branch.go16
-rw-r--r--routers/repo/release.go25
2 files changed, 39 insertions, 2 deletions
diff --git a/routers/repo/branch.go b/routers/repo/branch.go
index cf6abc08df..ac6b7a1bed 100644
--- a/routers/repo/branch.go
+++ b/routers/repo/branch.go
@@ -20,6 +20,7 @@ import (
"code.gitea.io/gitea/modules/util"
"code.gitea.io/gitea/modules/web"
"code.gitea.io/gitea/routers/utils"
+ release_service "code.gitea.io/gitea/services/release"
repo_service "code.gitea.io/gitea/services/repository"
)
@@ -383,7 +384,14 @@ func CreateBranch(ctx *context.Context) {
}
var err error
- if ctx.Repo.IsViewBranch {
+
+ if form.CreateTag {
+ if ctx.Repo.IsViewTag {
+ err = release_service.CreateNewTag(ctx.User, ctx.Repo.Repository, ctx.Repo.CommitID, form.NewBranchName, "")
+ } else {
+ err = release_service.CreateNewTag(ctx.User, ctx.Repo.Repository, ctx.Repo.BranchName, form.NewBranchName, "")
+ }
+ } else if ctx.Repo.IsViewBranch {
err = repo_module.CreateNewBranch(ctx.User, ctx.Repo.Repository, ctx.Repo.BranchName, form.NewBranchName)
} else if ctx.Repo.IsViewTag {
err = repo_module.CreateNewBranchFromCommit(ctx.User, ctx.Repo.Repository, ctx.Repo.CommitID, form.NewBranchName)
@@ -432,6 +440,12 @@ func CreateBranch(ctx *context.Context) {
return
}
+ if form.CreateTag {
+ ctx.Flash.Success(ctx.Tr("repo.tag.create_success", form.NewBranchName))
+ ctx.Redirect(ctx.Repo.RepoLink + "/src/tag/" + util.PathEscapeSegments(form.NewBranchName))
+ return
+ }
+
ctx.Flash.Success(ctx.Tr("repo.branch.create_success", form.NewBranchName))
ctx.Redirect(ctx.Repo.RepoLink + "/src/branch/" + util.PathEscapeSegments(form.NewBranchName))
}
diff --git a/routers/repo/release.go b/routers/repo/release.go
index b4370bb09b..d89a173669 100644
--- a/routers/repo/release.go
+++ b/routers/repo/release.go
@@ -262,6 +262,29 @@ func NewReleasePost(ctx *context.Context) {
return
}
+ msg := ""
+ if len(form.Title) > 0 && form.AddTagMsg {
+ msg = form.Title + "\n\n" + form.Content
+ }
+
+ if len(form.TagOnly) > 0 {
+ if err = releaseservice.CreateNewTag(ctx.User, ctx.Repo.Repository, form.Target, form.TagName, msg); err != nil {
+ if models.IsErrTagAlreadyExists(err) {
+ e := err.(models.ErrTagAlreadyExists)
+ ctx.Flash.Error(ctx.Tr("repo.branch.tag_collision", e.TagName))
+ ctx.Redirect(ctx.Repo.RepoLink + "/src/" + ctx.Repo.BranchNameSubURL())
+ return
+ }
+
+ ctx.ServerError("releaseservice.CreateNewTag", err)
+ return
+ }
+
+ ctx.Flash.Success(ctx.Tr("repo.tag.create_success", form.TagName))
+ ctx.Redirect(ctx.Repo.RepoLink + "/src/tag/" + form.TagName)
+ return
+ }
+
rel = &models.Release{
RepoID: ctx.Repo.Repository.ID,
PublisherID: ctx.User.ID,
@@ -274,7 +297,7 @@ func NewReleasePost(ctx *context.Context) {
IsTag: false,
}
- if err = releaseservice.CreateRelease(ctx.Repo.GitRepo, rel, attachmentUUIDs); err != nil {
+ if err = releaseservice.CreateRelease(ctx.Repo.GitRepo, rel, attachmentUUIDs, msg); err != nil {
ctx.Data["Err_TagName"] = true
switch {
case models.IsErrReleaseAlreadyExist(err):