Is it possible in Gitlab to disable force push for all branches, but allow to delete them? -
we use gitlab , want disable force pushes , rebase developers, want them able merge , delete branches, except protected ones. , want spread these rules our gitlab projects (there 130 of them) , branches. possible?
we tried use protected branches - in addition protected master
mark branches protected (wildcard *
), , allow developers push , merge, protected branches prohibited deletion (even when merge request accepted), doesn't work us. hope can suggest working solution.
the solution found create global custom hook (according https://docs.gitlab.com/ce/administration/custom_hooks.html , https://stackoverflow.com/a/17064462/2190541). i've created executable file gitlab-shell/hooks/pre-receive.d/disable-force-push.sh
following content:
#!/bin/sh # <oldrev> <newrev> <refname> # update blame tree while read oldrev newrev ref ; # old revision blank - branch creation if [ "$oldrev" = "0000000000000000000000000000000000000000" ] || # new revision blank - branch deletion [ "$newrev" = "0000000000000000000000000000000000000000" ] ; # create new or delete old branch continue; fi base=$(git merge-base $oldrev $newrev); if [ "$base" != "$oldrev" ] ; # non fast forward merge echo "force pushing of $ref forbidden"; exit 1; fi done exit 0;
Comments
Post a Comment