diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2016-12-31 19:51:12 +0800 |
---|---|---|
committer | Kim "BKC" Carlbäcker <kim.carlbacker@gmail.com> | 2017-01-03 02:27:38 +0100 |
commit | 3c7116382ff4783a89c443b7b36c30d27b9c461c (patch) | |
tree | 2b4463084bf3b86f371902de646acead80a006a0 | |
parent | 727675dd46c0b24edd45e1aa710b6b49bb9be202 (diff) | |
download | gitea-3c7116382ff4783a89c443b7b36c30d27b9c461c.tar.gz gitea-3c7116382ff4783a89c443b7b36c30d27b9c461c.zip |
change the default action when deleting a release to not delete tag
-rw-r--r-- | models/release.go | 14 | ||||
-rw-r--r-- | routers/repo/release.go | 3 |
2 files changed, 10 insertions, 7 deletions
diff --git a/models/release.go b/models/release.go index bb5f43407b..428b79e45f 100644 --- a/models/release.go +++ b/models/release.go @@ -249,7 +249,7 @@ func UpdateRelease(gitRepo *git.Repository, rel *Release) (err error) { } // DeleteReleaseByID deletes a release and corresponding Git tag by given ID. -func DeleteReleaseByID(id int64, u *User) error { +func DeleteReleaseByID(id int64, u *User, delTag bool) error { rel, err := GetReleaseByID(id) if err != nil { return fmt.Errorf("GetReleaseByID: %v", err) @@ -267,11 +267,13 @@ func DeleteReleaseByID(id int64, u *User) error { return fmt.Errorf("DeleteReleaseByID: permission denied") } - _, stderr, err := process.ExecDir(-1, repo.RepoPath(), - fmt.Sprintf("DeleteReleaseByID (git tag -d): %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 delTag { + _, stderr, err := process.ExecDir(-1, repo.RepoPath(), + fmt.Sprintf("DeleteReleaseByID (git tag -d): %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 { diff --git a/routers/repo/release.go b/routers/repo/release.go index 9e4764db0e..371ea3b597 100644 --- a/routers/repo/release.go +++ b/routers/repo/release.go @@ -304,7 +304,8 @@ func EditReleasePost(ctx *context.Context, form auth.EditReleaseForm) { // DeleteRelease delete a release func DeleteRelease(ctx *context.Context) { - if err := models.DeleteReleaseByID(ctx.QueryInt64("id"), ctx.User); err != nil { + delTag := ctx.QueryBool("delTag") + if err := models.DeleteReleaseByID(ctx.QueryInt64("id"), ctx.User, delTag); err != nil { ctx.Flash.Error("DeleteReleaseByID: " + err.Error()) } else { ctx.Flash.Success(ctx.Tr("repo.release.deletion_success")) |