我正在尝试编写服务器端预接收git挂钩来评估提交时的提交.
根据这里的答案,通过搜索git日志并使用'format:'过滤掉我想要的内容,这很容易实现.
我创建了以下预提交脚本.
#!/bin/bash
set -x #for debugging, TODO: remove
echo "parameters are" $@
echo "1 is " $1
#List of banned users
bannedusers=( root )
author_name=$(git show --pretty=oneline --pretty=format:%an | head -n1)
author_email=$(git show --pretty=oneline --pretty=format:%ae | head -n1)
committer_name=$(git show --pretty=oneline --pretty=format:%cn | head -n1)
committer_email=$(git show --pretty=oneline --pretty=format:%ce | head -n1)
commit_users=( "${author_name}" "${committer_name}" )
for acommituser in "${commit_users[@]}"
do
:
echo $acommituser #for debugging, TODO: remove
for abanneduser in "${bannedusers[@]}"
do
: …Run Code Online (Sandbox Code Playgroud)