aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--models/release.go6
-rw-r--r--routers/repo/release.go3
-rw-r--r--routers/repo/setting.go4
3 files changed, 5 insertions, 8 deletions
diff --git a/models/release.go b/models/release.go
index 1df6272029..e6c3d56152 100644
--- a/models/release.go
+++ b/models/release.go
@@ -50,7 +50,7 @@ func IsReleaseExist(repoId int64, tagName string) (bool, error) {
}
// 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)
if err != nil {
return err
@@ -58,8 +58,8 @@ func CreateRelease(repoPath string, rel *Release, gitRepo *git.Repository) error
return ErrReleaseAlreadyExist
}
- if !git.IsTagExist(repoPath, rel.TagName) {
- _, stderr, err := com.ExecCmdDir(repoPath, "git", "tag", rel.TagName, "-m", rel.Title)
+ if !gitRepo.IsTagExist(rel.TagName) {
+ _, stderr, err := com.ExecCmdDir(gitRepo.Path, "git", "tag", rel.TagName, "-m", rel.Title)
if err != nil {
return err
} else if strings.Contains(stderr, "fatal:") {
diff --git a/routers/repo/release.go b/routers/repo/release.go
index b386bac804..14a14656d4 100644
--- a/routers/repo/release.go
+++ b/routers/repo/release.go
@@ -140,8 +140,7 @@ func ReleasesNewPost(ctx *middleware.Context, form auth.NewReleaseForm) {
IsPrerelease: form.Prerelease,
}
- if err = models.CreateRelease(models.RepoPath(ctx.User.Name, ctx.Repo.Repository.Name),
- rel, ctx.Repo.GitRepo); err != nil {
+ if err = models.CreateRelease(ctx.Repo.GitRepo, rel); err != nil {
if err == models.ErrReleaseAlreadyExist {
ctx.RenderWithErr("Release with this tag name has already existed", "release/new", &form)
} else {
diff --git a/routers/repo/setting.go b/routers/repo/setting.go
index d7c273c63a..89c7cb486e 100644
--- a/routers/repo/setting.go
+++ b/routers/repo/setting.go
@@ -10,8 +10,6 @@ import (
"github.com/go-martini/martini"
- "github.com/gogits/git"
-
"github.com/gogits/gogs/models"
"github.com/gogits/gogs/modules/auth"
"github.com/gogits/gogs/modules/base"
@@ -57,7 +55,7 @@ func SettingPost(ctx *middleware.Context, form auth.RepoSettingForm) {
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.Description = form.Description