Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Blocking tag moves in stash

Bradley Baetz July 13, 2014

I'm trying to work out how to block tags from being moved in a stash repository. I have the 'reject force push' plugin enabled (on stash3.1.3), but it doesn't seem to work reliably with tags.

Starting with an empty repository:

echo "A" > file
git add file; git commit -m 'add' file; git push
git tag -a -m 'tag' test; git push --tags
echo "B" > file
git add file; git commit -m 'change' file; git push
git tag -a -f -m 'tag2' test
git push --tags --force # This should error, but doesn't
git tag -a -f -m 'tag-back' test HEAD^ # Move the tag back to the original position
git push --tags --force # This does error

I suspect that the code is assuming that a move-forward is always OK? This is true for force pushes to branches, but not for tags.

I've also tried the 'force field' plugin from the marketplace, but get the same result.

Not sure if this is a bug or a missing feature?

However, even if it is a bug I think that I'm going to have to write my own plugin to ban tag deletions anyway.

A bit of testing seems to show that a prereceive hook that blocks refChanges where (refChange.getType != RefChangeType.ADD && refChange.getRefId().startsWith("refs/tags/")) will work - is that right?

I can't work out what the from/to hash ids are for an UPDATE to a tag, so I'm worried I'm missing something...

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Balázs Szakmáry
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 13, 2014

This looks like a bug (anything with --force swhould fail). Report it here.

Bradley Baetz July 13, 2014

Done. I was hoping I was missing something obvious.

0 votes
James Gorman
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 16, 2014

Thanks for adding the bug Bradley, this is being fixed in Stash 3.2

https://jira.atlassian.com/browse/STASH-4990

TAGS
AUG Leaders

Atlassian Community Events