Reputation: 1369
i' m very newbie to git hooks. I' d like to make sure that to the repository only branches will be pushed / updated which starts with BT. So no update is possible to master / current branch. How can i achieve that? I guess it should be part of the update script, right?
Upvotes: 1
Views: 406
Reputation: 30858
It could be a pre-receive
hook.
#!/bin/bash
#sample
z40=0000000000000000000000000000000000000000
while read old new ref;do
#fail if it's not a branch or the name of the branch does not start with BT
if [ "${ref:0:13}" != "refs/heads/BT" ];then
echo "Error: not allowed to update $ref"
exit 1
fi
#deal with other cases if necessary
#create a ref, branch or tag
if [ "$old" = "$z40" ];then
:
fi
#delete a ref, branch or tag
if [ "$new" = "$z40" ];then
:
fi
done
Upvotes: 2