1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-12-22 12:54:53 -05:00

change the default action when deleting a release to not delete tag

This commit is contained in:
Lunny Xiao 2016-12-31 19:51:12 +08:00 committed by Kim "BKC" Carlbäcker
parent 727675dd46
commit 3c7116382f
2 changed files with 10 additions and 7 deletions

View file

@ -249,7 +249,7 @@ func UpdateRelease(gitRepo *git.Repository, rel *Release) (err error) {
} }
// DeleteReleaseByID deletes a release and corresponding Git tag by given ID. // 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) rel, err := GetReleaseByID(id)
if err != nil { if err != nil {
return fmt.Errorf("GetReleaseByID: %v", err) return fmt.Errorf("GetReleaseByID: %v", err)
@ -267,11 +267,13 @@ func DeleteReleaseByID(id int64, u *User) error {
return fmt.Errorf("DeleteReleaseByID: permission denied") return fmt.Errorf("DeleteReleaseByID: permission denied")
} }
_, stderr, err := process.ExecDir(-1, repo.RepoPath(), if delTag {
fmt.Sprintf("DeleteReleaseByID (git tag -d): %d", rel.ID), _, stderr, err := process.ExecDir(-1, repo.RepoPath(),
"git", "tag", "-d", rel.TagName) fmt.Sprintf("DeleteReleaseByID (git tag -d): %d", rel.ID),
if err != nil && !strings.Contains(stderr, "not found") { "git", "tag", "-d", rel.TagName)
return fmt.Errorf("git tag -d: %v - %s", err, stderr) 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 { if _, err = x.Id(rel.ID).Delete(new(Release)); err != nil {

View file

@ -304,7 +304,8 @@ func EditReleasePost(ctx *context.Context, form auth.EditReleaseForm) {
// DeleteRelease delete a release // DeleteRelease delete a release
func DeleteRelease(ctx *context.Context) { 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()) ctx.Flash.Error("DeleteReleaseByID: " + err.Error())
} else { } else {
ctx.Flash.Success(ctx.Tr("repo.release.deletion_success")) ctx.Flash.Success(ctx.Tr("repo.release.deletion_success"))