mirror of
https://github.com/go-gitea/gitea
synced 2024-11-19 00:11:24 +01:00
update with git api
This commit is contained in:
parent
2eabeba6b7
commit
7d84cc96e8
3 changed files with 5 additions and 8 deletions
|
@ -50,7 +50,7 @@ func IsReleaseExist(repoId int64, tagName string) (bool, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateRelease creates a new release of repository.
|
// CreateRelease creates a new release of repository.
|
||||||
func CreateRelease(repoPath string, rel *Release, gitRepo *git.Repository) error {
|
func CreateRelease(gitRepo *git.Repository, rel *Release) error {
|
||||||
isExist, err := IsReleaseExist(rel.RepoId, rel.TagName)
|
isExist, err := IsReleaseExist(rel.RepoId, rel.TagName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -58,8 +58,8 @@ func CreateRelease(repoPath string, rel *Release, gitRepo *git.Repository) error
|
||||||
return ErrReleaseAlreadyExist
|
return ErrReleaseAlreadyExist
|
||||||
}
|
}
|
||||||
|
|
||||||
if !git.IsTagExist(repoPath, rel.TagName) {
|
if !gitRepo.IsTagExist(rel.TagName) {
|
||||||
_, stderr, err := com.ExecCmdDir(repoPath, "git", "tag", rel.TagName, "-m", rel.Title)
|
_, stderr, err := com.ExecCmdDir(gitRepo.Path, "git", "tag", rel.TagName, "-m", rel.Title)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
} else if strings.Contains(stderr, "fatal:") {
|
} else if strings.Contains(stderr, "fatal:") {
|
||||||
|
|
|
@ -140,8 +140,7 @@ func ReleasesNewPost(ctx *middleware.Context, form auth.NewReleaseForm) {
|
||||||
IsPrerelease: form.Prerelease,
|
IsPrerelease: form.Prerelease,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = models.CreateRelease(models.RepoPath(ctx.User.Name, ctx.Repo.Repository.Name),
|
if err = models.CreateRelease(ctx.Repo.GitRepo, rel); err != nil {
|
||||||
rel, ctx.Repo.GitRepo); err != nil {
|
|
||||||
if err == models.ErrReleaseAlreadyExist {
|
if err == models.ErrReleaseAlreadyExist {
|
||||||
ctx.RenderWithErr("Release with this tag name has already existed", "release/new", &form)
|
ctx.RenderWithErr("Release with this tag name has already existed", "release/new", &form)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -10,8 +10,6 @@ import (
|
||||||
|
|
||||||
"github.com/go-martini/martini"
|
"github.com/go-martini/martini"
|
||||||
|
|
||||||
"github.com/gogits/git"
|
|
||||||
|
|
||||||
"github.com/gogits/gogs/models"
|
"github.com/gogits/gogs/models"
|
||||||
"github.com/gogits/gogs/modules/auth"
|
"github.com/gogits/gogs/modules/auth"
|
||||||
"github.com/gogits/gogs/modules/base"
|
"github.com/gogits/gogs/modules/base"
|
||||||
|
@ -57,7 +55,7 @@ func SettingPost(ctx *middleware.Context, form auth.RepoSettingForm) {
|
||||||
|
|
||||||
br := form.Branch
|
br := form.Branch
|
||||||
|
|
||||||
if git.IsBranchExist(models.RepoPath(ctx.User.Name, ctx.Repo.Repository.Name), br) {
|
if ctx.Repo.GitRepo.IsBranchExist(br) {
|
||||||
ctx.Repo.Repository.DefaultBranch = br
|
ctx.Repo.Repository.DefaultBranch = br
|
||||||
}
|
}
|
||||||
ctx.Repo.Repository.Description = form.Description
|
ctx.Repo.Repository.Description = form.Description
|
||||||
|
|
Loading…
Reference in a new issue