如果有人在推送其他提交之前,我想阻止在GitLab上执行推送。我会强迫他先拉,然后进行互动式变基。我以为我需要服务器端git钩子。
我的这篇红色文章:https://docs.gitlab.com/ce/administration/server_hooks.html
但是我停留在这一行:gitlab-runner
如何登录到GitLab?我安装了
// By default, the client will authenticate using the service account file
// specified by the GOOGLE_APPLICATION_CREDENTIALS environment variable and use
// the project specified by the GCLOUD_PROJECT environment variable. See
// https://cloud.google.com/docs/authentication/production#providing_credentials_to_your_application
const Compute = require('@google-cloud/compute');
rejectUnauthorized: false;//add when working with https sites
requestCert: false;//add when working with https sites
agent: false;//add when working with https sites
// Creates a client
const compute = new Compute();
async function getVmsExample() {
// In this example we only want one VM per page
const options = {
maxResults: 1,
};
const vms = await compute.getVMs(options);
return vms;
}
// Run the examples
exports.main = async () => {
const vms = await getVmsExample().catch(console.error);
if (vms) console.log('VMs:', vms);
return vms;
};
if (module === require.main) {
exports.main(console.log);
}
,但不知道如何“登录”并将预接收脚本添加到hooks子目录中。
你有什么主意吗?
答案 0 :(得分:1)
Protecting the branch应该足够:这样可以防止强行将其推入分支。
而且可以通过GitLab GUI进行设置,而无需登录到GitLab服务器。
这意味着:如果有人已经推动过,那么您将必须先拉动,然后才能推动自己。