pre-receive hooks in GIT (using bash on Linux) to filter the push that are allowed into my repo.
I need to filter the push that developers do into my GIT repo, allowing just pushed with this requisites (
# is number):
# Commits > 0 && # Tags != 0: NO
# Commits > 0 && # Tags == 0: YES
# Commits == 0 && # Tags > 1: NO
# Commits == 0 && # Tags == 1&&
Key is correct: YES
Consider branches and other operations same as commits. You can only push a single tag using the right key (specified in tag comment). You can't push a tag with other elements.
The problem is that
$refname only have the HEAD ref, so if you do this order:
Tag(to any revision, even oldies)
$refname will point to the last reference (i.e.
/refs/heads/master), so doing:
if [[ "$refname" == "refs/tags/"* ]]; then
Won't work in the order mentionated. I tried to iterate through references using
for-each-ref, without success.
How could I process the push being received, knowing the number of tags (and getting the comment of each one) to satisfy the upper conditions?
PS: Consider also the situation of pushing with --all option, receiving more than one branch.