gpt4 book ai didi

git - 锁定分支但允许 gitlab merge 请求

转载 作者:太空狗 更新时间:2023-10-29 14:29:09 25 4
gpt4 key购买 nike

我们使用的是 GitLab 8.5.0 版。我正在编写一个自定义服务器端更新 Hook 来锁定特定的分支。它工作得很好,但是,我想允许处理 GitLab merge 请求。所有 GitLab merge 请求通常在提交描述中都有“查看 merge 请求”注释。因此,我认为只允许那些包含提交消息“查看 merge 请求”的提交。但是,它并不像我想的那样工作。

任何其他可能的方法只允许 gitlab merge 请求?

#!/usr/bin/env bash

GIT_COMMIT_MSG=`git log -1 HEAD --pretty=format:%s`

if [[ "$1" == refs/heads/master ]]; then
if [[ "$GIT_COMMIT_MSG" =~ *"See Merge request"* ]]; then
echo "This is GitLab Merge Request"
else
echo $GIT_COMMIT_MSG
echo "ERROR: you are not allowed to update master" >&2
exit 1
fi

fi

最佳答案

我知道您使用的是 GitLab 8.5,但如果可能,请考虑升级到 8.11,该版本已在本地(并且更安全地)实现。
参见“Using the Allowed to merge and Allowed to push settings

You could set "Allowed to push" to "No one", and "Allowed to merge" to "Developers + Masters", to require everyone to submit a merge request for changes going into the protected branch.

enter image description here

那么你只需要保护一些分支,它们只会通过 merge 请求进行修改。

关于git - 锁定分支但允许 gitlab merge 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40702087/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com