Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tag/release deletion #10663

Merged
merged 1 commit into from
Mar 8, 2020
Merged

Fix tag/release deletion #10663

merged 1 commit into from
Mar 8, 2020

Conversation

jolheiser
Copy link
Member

Currently you cannot delete a light tag from a repo because deleting a tag is never a "new tag".

  1. Create a repo
  2. Push a new light tag git tag test && git push --tags
  3. Delete the tag and update it in remote git tag -d test && git push origin :test
  4. Tag still shows up in release tab

@jolheiser jolheiser added this to the 1.12.0 milestone Mar 8, 2020
@codecov-io
Copy link

Codecov Report

Merging #10663 into master will decrease coverage by 0.01%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #10663      +/-   ##
==========================================
- Coverage    43.6%   43.58%   -0.02%     
==========================================
  Files         588      588              
  Lines       82485    82485              
==========================================
- Hits        35965    35954      -11     
- Misses      42059    42066       +7     
- Partials     4461     4465       +4
Impacted Files Coverage Δ
modules/repofiles/update.go 38.69% <0%> (-0.39%) ⬇️
modules/indexer/stats/queue.go 62.5% <0%> (-18.75%) ⬇️
modules/indexer/stats/db.go 40.62% <0%> (-18.75%) ⬇️
modules/git/utils.go 65.67% <0%> (-4.48%) ⬇️
modules/queue/unique_queue_disk_channel.go 53.84% <0%> (-1.93%) ⬇️
services/pull/pull.go 34.7% <0%> (-1.18%) ⬇️
modules/queue/workerpool.go 56.93% <0%> (-1.07%) ⬇️
modules/log/event.go 64.61% <0%> (-1.03%) ⬇️
modules/git/repo.go 46.78% <0%> (-0.92%) ⬇️
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4901096...78728a6. Read the comment docs.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Mar 8, 2020
Copy link
Member

@guillep2k guillep2k left a comment

Choose a reason for hiding this comment

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

Maybe this also needs a revision:

// If is tag reference
tagName := opts.TagName()
if opts.IsDelRef() {
delTags = append(delTags, tagName)
} else {
cache.Remove(repo.GetCommitsCountCacheKey(tagName, true))
addTags = append(addTags, tagName)
}

Looks like the cache.Remove() call should be inside the if opts.IsDelRef() block rather than the else.

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Mar 8, 2020
@jolheiser
Copy link
Member Author

jolheiser commented Mar 8, 2020

Maybe? I'm not sure, as back in the 1.11 branch before this was changed it was still in the latter block.

if strings.HasPrefix(opts.RefFullName, git.TagPrefix) {
// If is tag reference
tagName := opts.RefFullName[len(git.TagPrefix):]
if isDelRef {
delTags = append(delTags, tagName)
} else {
cache.Remove(repo.GetCommitsCountCacheKey(tagName, true))
addTags = append(addTags, tagName)

Same in 1.10 branch

if strings.HasPrefix(opts.RefFullName, git.TagPrefix) {
// If is tag reference
tagName := opts.RefFullName[len(git.TagPrefix):]
if isDelRef {
err = models.PushUpdateDeleteTag(repo, tagName)
if err != nil {
return fmt.Errorf("PushUpdateDeleteTag: %v", err)
}
} else {
// Clear cache for tag commit count
cache.Remove(repo.GetCommitsCountCacheKey(tagName, true))
err = models.PushUpdateAddTag(repo, gitRepo, tagName)
if err != nil {
return fmt.Errorf("PushUpdateAddTag: %v", err)
}
}

Of course, that's not to say it isn't a bug that's been around for a while. 😅

@guillep2k
Copy link
Member

Maybe? I'm not sure, as back in the 1.11 branch before this was changed it was still in the latter block.

Yeah, but what could we be having cached about a ref that didn't exist before? Notice it's using tagName as the key. And why aren't we clearing the cache on the deleted ref?

I can't follow the code ATM, but it's truly suspicious. 🤔

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Mar 8, 2020
@lunny
Copy link
Member

lunny commented Mar 8, 2020

@lunny lunny merged commit b40428a into go-gitea:master Mar 8, 2020
@jolheiser jolheiser deleted the del-tag branch March 8, 2020 13:30
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants