考虑以下情况:
Alice对Bob的提交进行结帐/挑选,但仍未提交给主人。
Bob为此提交推送了新的补丁集。爱丽丝不知道。
Alice根据Bob提交的过时版本推送她的新提交,gerrit也根据Change-ID将新补丁集应用于Bob的提交,覆盖了Bob的最新更改。
git / gerrit中是否有任何方法可以防止这种情况发生?
答案 0 :(得分:1)
我使用git pre-push hook实现了我需要的东西。 这是我的.git / pre-push文件的内容:
#!/bin/sh
# A hook script to verify what is about to be pushed. Called by "git
# push" after it has checked the remote status, but before anything has been
# pushed. If this script exits with a non-zero status nothing will be pushed.
#
# This hook is called with the following parameters:
#
# $1 -- Name of the remote to which the push is being done
# $2 -- URL to which the push is being done
#
# If pushing without using a named remote those arguments will be equal.
#
# Information about the commits which are being pushed is supplied as lines to
# the standard input in the form:
#
# <local ref> <local sha1> <remote ref> <remote sha1>
AUTHOR=$(git var GIT_AUTHOR_IDENT)
while read local_ref local_sha remote_ref remote_sha
do
commit_author=$(git log -1 --pretty=format:"%ae" $local_sha)
#echo $local_ref $local_sha $remote_ref $remote_sha $commit_author
found=`echo $AUTHOR | grep -c "$commit_author"`
if [ $found == 0 ]
then
echo
echo "REJECTED by local pre-push hook:"
echo "You are trying to push some other's commit: $local_sha $commit_author"
echo "Use --no-verify if you are sure this is not an error"
exit -1
fi
done
echo "Local pre-push verify passed ok"
exit 0
答案 1 :(得分:0)
您可以更改“Forge Author”默认权限:
通常Gerrit需要作者和提交者身份行 在Git提交对象(或带注释的标记中的标记行)中进行匹配 上传用户的一个注册电子邮件地址。这个 权限允许用户绕过部分验证,这可能是 在镜像来自上游项目的更改时是必要的。
允许在提交对象中使用未经验证的作者行。在应用来自3rd的电子邮件收到的补丁时,这非常有用 派对,当采摘其他人写的变化时 分支机构,或修改别人承诺解决未成年人的问题 提交前的问题。
默认情况下,这会授予所有项目中的注册用户,但如果验证作者身份,则网站管理员可能会将其禁用 必需的。
更多信息:https://gerrit.cpqd.com.br/Documentation/access-control.html#category_forge_author