问题描述
我有一个问题,有一个css样式文件,这个文件不应该被开发团队中的任何人修改,只有管理员(我):)
有什么办法来锁定文件。我在提交中看到,该文件已被更改,但我不希望发生这种情况。
我可以做什么?
我使用gitblit服务器,而git使用git-extensions。
非常感谢您的回答。
这必须在服务器上完成,通过。检查。在收到推送数据后,服务器会运行post-receive挂钩,如果它返回false,推送将被拒绝。
当脚本被调用时你会得到一个refs列表,参见示例中的如何获取提交列表
这应该让您开始获取推送中包含的文件列表:
$ b
def commits = JGitUtils.getRevLog(repository,command.oldId.name,command.newId。 name)
提交提交:
def diffs = git.diff()。setNewTree(commit.getTree())
.setOldTree(commit.getParent(0).getTree())
.call();
用于比较差异:
def path = diff.getOldPath();
//检查路径中的扩展名,并返回false以拒绝推送
I have a problem, there is a css style file, this file should not be modified by anyone from the development team, only the administrator (me) :)
There any way to lock the file. I have seen in the commits, that the file has been changed, but I do not want this to happen.
What I can do?
I use gitblit server, and git with git-extensions.
thank you very much for your answers.
This must be done on the server, by setup a hook within Gitblit. Check one of the provided post-receive hooks. A post-receive hook is run by the server after the push data has been received, and if it returns false the push will be rejected.
When the script will get invoked you get a list of refs, see in the example how to get the list of commits
This should get you started to get a list of the files contained in the push:
def commits = JGitUtils.getRevLog(repository, command.oldId.name, command.newId.name)
for commit in commits:
def diffs = git.diff().setNewTree(commit.getTree())
.setOldTree(commit.getParent(0).getTree())
.call();
for diff in diffs:
def path = diff.getOldPath();
//check the extension on the path, and return false to reject the push
这篇关于阻止Git存储库中某些用户的特定文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!