开发者

Git hook to disallow directory creation in top level

开发者 https://www.devze.com 2023-01-09 08:06 出处:网络
Any b开发者_如何转开发etter way to prevent stop top level directory creation by users may be while on push or direct file creation?This answer supplements VonC answer.

Any b开发者_如何转开发etter way to prevent stop top level directory creation by users may be while on push or direct file creation?


This answer supplements VonC answer.


As each developer should have his/her own clone (his/her own working repository), the only control you can realistically impose1 is on allowing or disallowing during push to publish repository (or during you pulling their changes). This can be done using update or pre-receive hook.

1) The pre-commit hook can be bypassed with "git commit --no-verify"

I don't know if any ready solution support constraint you want to impose, but I think that both update-paranoid example hook (from contrib/hooks in git sources), and gitolite (the tool to manage access to git repositories) can be extended to support it; both can do path based / diff based constraints, for example allow changes only to given configured subdirectory.


You can try a client-side hook, like a

The pre-commit hook is run first, before you even type in a commit message.
It’s used to inspect the snapshot that’s about to be committed, to see if you’ve forgotten something, to make sure tests run, or to examine whatever you need to inspect in the code. Exiting non-zero from this hook aborts the commit, although you can bypass it with git commit --no-verify.

See this example of advance pre-commit hook to see what it is possible to do in term of checking the index content.


If you really want that level of control over what goes into the master repository, don't let other people push to it. Instead, have the manager pull from other users and review their changes to make sure they haven't violated policies.

0

精彩评论

暂无评论...
验证码 换一张
取 消