tokarchuk/v1.17
Unknwon 9 years ago
parent 9b6c835715
commit 987dcc5372
  1. 2
      README.md
  2. 1
      cmd/web.go
  3. 4
      conf/locale/locale_en-US.ini
  4. 2
      gogs.go
  5. 3
      models/error.go
  6. 4
      models/issue.go
  7. 51
      models/release.go
  8. 4
      modules/bindata/bindata.go
  9. 3
      modules/git/repo.go
  10. 17
      routers/repo/release.go
  11. 2
      templates/.VERSION
  12. 1
      templates/repo/release/list.tmpl
  13. 16
      templates/repo/release/new.tmpl

@ -5,7 +5,7 @@ Gogs - Go Git Service [![Build Status](https://travis-ci.org/gogits/gogs.svg?bra
![](public/img/gogs-large-resize.png)
##### Current version: 0.7.18 Beta
##### Current version: 0.7.19 Beta
<table>
<tr>

@ -514,6 +514,7 @@ func runWeb(ctx *cli.Context) {
m.Post("/new", bindIgnErr(auth.NewReleaseForm{}), repo.NewReleasePost)
m.Get("/edit/:tagname", repo.EditRelease)
m.Post("/edit/:tagname", bindIgnErr(auth.EditReleaseForm{}), repo.EditReleasePost)
m.Post("/delete", repo.DeleteRelease)
}, reqRepoAdmin, middleware.RepoRef())
m.Combo("/compare/*").Get(repo.CompareAndPullRequest).

@ -655,6 +655,10 @@ release.cancel = Cancel
release.publish = Publish Release
release.save_draft = Save Draft
release.edit_release = Edit Release
release.delete_release = Delete This Release
release.deletion = Release Deletion
release.deletion_desc = Delete this release will delete corresponding Git tag. Do you want to continue?
release.deletion_success = Release has been deleted successfully!
release.tag_name_already_exist = Release with this tag name has already existed.
release.downloads = Downloads

@ -17,7 +17,7 @@ import (
"github.com/gogits/gogs/modules/setting"
)
const APP_VER = "0.7.18.1119 Beta"
const APP_VER = "0.7.19.1120 Beta"
func init() {
runtime.GOMAXPROCS(runtime.NumCPU())

@ -330,6 +330,7 @@ func (err ErrReleaseAlreadyExist) Error() string {
}
type ErrReleaseNotExist struct {
ID int64
TagName string
}
@ -339,7 +340,7 @@ func IsErrReleaseNotExist(err error) bool {
}
func (err ErrReleaseNotExist) Error() string {
return fmt.Sprintf("Release tag does not exist [tag_name: %s]", err.TagName)
return fmt.Sprintf("Release tag does not exist [id: %d, tag_name: %s]", err.ID, err.TagName)
}
// __ __ ___. .__ __

@ -1375,8 +1375,8 @@ func ChangeMilestoneAssign(oldMid int64, issue *Issue) (err error) {
}
// DeleteMilestoneByID deletes a milestone by given ID.
func DeleteMilestoneByID(mid int64) error {
m, err := GetMilestoneByID(mid)
func DeleteMilestoneByID(id int64) error {
m, err := GetMilestoneByID(id)
if err != nil {
if IsErrMilestoneNotExist(err) {
return nil

@ -5,6 +5,7 @@
package models
import (
"fmt"
"sort"
"strings"
"time"
@ -12,6 +13,7 @@ import (
"github.com/go-xorm/xorm"
"github.com/gogits/gogs/modules/git"
"github.com/gogits/gogs/modules/process"
)
// Release represents a release of repository.
@ -99,7 +101,7 @@ func GetRelease(repoID int64, tagName string) (*Release, error) {
if err != nil {
return nil, err
} else if !isExist {
return nil, ErrReleaseNotExist{tagName}
return nil, ErrReleaseNotExist{0, tagName}
}
rel := &Release{RepoID: repoID, LowerTagName: strings.ToLower(tagName)}
@ -107,8 +109,21 @@ func GetRelease(repoID int64, tagName string) (*Release, error) {
return rel, err
}
// GetReleasesByRepoId returns a list of releases of repository.
func GetReleasesByRepoId(repoID int64) (rels []*Release, err error) {
// GetReleaseByID returns release with given ID.
func GetReleaseByID(id int64) (*Release, error) {
rel := new(Release)
has, err := x.Id(id).Get(rel)
if err != nil {
return nil, err
} else if !has {
return nil, ErrReleaseNotExist{id, ""}
}
return rel, nil
}
// GetReleasesByRepoID returns a list of releases of repository.
func GetReleasesByRepoID(repoID int64) (rels []*Release, err error) {
err = x.Desc("created").Find(&rels, Release{RepoID: repoID})
return rels, err
}
@ -147,3 +162,33 @@ func UpdateRelease(gitRepo *git.Repository, rel *Release) (err error) {
_, err = x.Id(rel.ID).AllCols().Update(rel)
return err
}
// DeleteReleaseByID deletes a release and corresponding Git tag by given ID.
func DeleteReleaseByID(id int64) error {
rel, err := GetReleaseByID(id)
if err != nil {
return fmt.Errorf("GetReleaseByID: %v", err)
}
repo, err := GetRepositoryByID(rel.RepoID)
if err != nil {
return fmt.Errorf("GetRepositoryByID: %v", err)
}
repoPath, err := repo.RepoPath()
if err != nil {
return fmt.Errorf("RepoPath: %v", err)
}
_, stderr, err := process.ExecDir(-1, repoPath, fmt.Sprintf("Delete release [%d]", rel.ID),
"git", "tag", "-d", rel.TagName)
if err != nil && !strings.Contains(stderr, "not found") {
return fmt.Errorf("git tag -d: %v - %s", err, stderr)
}
if _, err = x.Id(rel.ID).Delete(new(Release)); err != nil {
return fmt.Errorf("Delete: %v", err)
}
return nil
}

File diff suppressed because one or more lines are too long

@ -5,6 +5,7 @@
package git
import (
"errors"
"path/filepath"
)
@ -21,6 +22,8 @@ func OpenRepository(repoPath string) (*Repository, error) {
repoPath, err := filepath.Abs(repoPath)
if err != nil {
return nil, err
} else if !isDir(repoPath) {
return nil, errors.New("no such file or directory")
}
return &Repository{Path: repoPath}, nil

@ -27,9 +27,9 @@ func Releases(ctx *middleware.Context) {
return
}
rels, err := models.GetReleasesByRepoId(ctx.Repo.Repository.ID)
rels, err := models.GetReleasesByRepoID(ctx.Repo.Repository.ID)
if err != nil {
ctx.Handle(500, "GetReleasesByRepoId", err)
ctx.Handle(500, "GetReleasesByRepoID", err)
return
}
@ -212,6 +212,7 @@ func EditRelease(ctx *middleware.Context) {
}
return
}
ctx.Data["ID"] = rel.ID
ctx.Data["tag_name"] = rel.TagName
ctx.Data["tag_target"] = rel.Target
ctx.Data["title"] = rel.Title
@ -257,3 +258,15 @@ func EditReleasePost(ctx *middleware.Context, form auth.EditReleaseForm) {
}
ctx.Redirect(ctx.Repo.RepoLink + "/releases")
}
func DeleteRelease(ctx *middleware.Context) {
if err := models.DeleteReleaseByID(ctx.QueryInt64("id")); err != nil {
ctx.Flash.Error("DeleteReleaseByID: " + err.Error())
} else {
ctx.Flash.Success(ctx.Tr("repo.release.deletion_success"))
}
ctx.JSON(200, map[string]interface{}{
"redirect": ctx.Repo.RepoLink + "/releases",
})
}

@ -1 +1 @@
0.7.18.1119 Beta
0.7.19.1120 Beta

@ -3,6 +3,7 @@
{{template "repo/header" .}}
<div class="ui container">
{{template "repo/sidebar" .}}
{{template "base/alert" .}}
<h2 class="ui header">
{{.i18n.Tr "repo.release.releases"}}
{{if .IsRepositoryAdmin}}

@ -68,6 +68,9 @@
<button class="ui green button">
{{.i18n.Tr "repo.release.edit_release"}}
</button>
<a class="ui red button delete-button" data-url="{{$.RepoLink}}/releases/delete" data-id="{{.ID}}">
{{$.i18n.Tr "repo.release.delete_release"}}
</a>
{{else}}
<button class="ui green button">
{{.i18n.Tr "repo.release.publish"}}
@ -80,4 +83,17 @@
</form>
</div>
</div>
{{if .PageIsEditRelease}}
<div class="ui small basic delete modal">
<div class="ui icon header">
<i class="trash icon"></i>
{{.i18n.Tr "repo.release.deletion"}}
</div>
<div class="content">
<p>{{.i18n.Tr "repo.release.deletion_desc"}}</p>
</div>
{{template "base/delete_modal_actions" .}}
</div>
{{end}}
{{template "base/footer" .}}
Loading…
Cancel
Save