Skip to content

Commit

Permalink
change the default action when deleting a release to not delete tag
Browse files Browse the repository at this point in the history
  • Loading branch information
lunny authored and bkcsoft committed Jan 3, 2017
1 parent 727675d commit 3c71163
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
14 changes: 8 additions & 6 deletions models/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion routers/repo/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down

2 comments on commit 3c71163

@yusiwen
Copy link

@yusiwen yusiwen commented on 3c71163 Jan 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lunny

The line 181: if err := models.DeleteReleaseByID(id, ctx.User); err != nil {

This commit is not going to be compiled successfully

@lunny
Copy link
Member Author

@lunny lunny commented on 3c71163 Jan 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, I have sent #562 to fix this.

Please sign in to comment.