gpt4 book ai didi

git/gitosis : How to check validity of user name and email?

转载 作者:IT王子 更新时间:2023-10-29 00:46:42 24 4
gpt4 key购买 nike

我已经安装了 git 和 gitosis,我需要在将内容推送到存储库时添加检查用户名是否有效。

我认为预接收钩子(Hook)是放置它的正确钩子(Hook),但我无法找到 gitosis 进入存储库的真实用户名和电子邮件地址(由 git config user.name 和 git 设置的)配置 user.email)来自环境变量。 LOGNAME 和 USER 都是“git”。 gitosis 如何检测此信息,我是否也可以在预接收 Hook 中找到它?

最佳答案

嗯,根据我从 githooks(5) 收集到的信息pre-receive Hook 获取 stdin 上更新的引用。

#!/bin/sh

while read old new name; do
email=$(git log -1 --pretty=format:%ae $new)
# check email
done

您需要检查电子邮件地址(可以有不止一行数据)并相应地退出脚本,即 exit 0 表示成功,例如exit 1 失败。

关于git/gitosis : How to check validity of user name and email?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/824990/

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