我需要强制每个新标签都成为注释标签。我需要让它强制适用于每个用户,而不需要告诉他们做任何特殊的事情。我尝试将标签别名设置为 "tag -a -m''",但它没有起作用。
我需要强制每个新标签都成为注释标签。我需要让它强制适用于每个用户,而不需要告诉他们做任何特殊的事情。我尝试将标签别名设置为 "tag -a -m''",但它没有起作用。
#!/bin/bash
git_command=$1
if [ "${git_command}" == "tag" ]; then
echo "User is trying to tag"
if [ "$2" != "-a" ] && [ "$2" != "-m" ]
then
echo lightweight
echo "Second option is not -a nor -m.So looks like user is trying to create a lighweight tag."
tag_message=$2
git tag -a ${tag_message} -m ""
else
git tag $2 $3 $4 $5
echo "Second option is either -a or -m. So may be user is trying to create an annotated tag."
fi
else
echo "User is not tagging. So continue with the git operation user requested."
fi
[alias]
atag = tag -a -m ""
然后git atag
创建一个带注释的标签。虽然不是很优雅,但比每次都要传递-m参数要好。