我的Git分支名称:
feature/ACD-1706_new-api-call
如果我在控制台中运行此脚本,它将正常工作:
bash -l -c 'current_branch="$(git rev-parse --abbrev-ref HEAD)" && no_feature=${current_branch##*/} && no_underscore=${no_feature%%_*} && history -s "git commit -m \"$no_underscore | " && echo "Press UP to start commit command:" && echo "" && read -e -p "> " && eval "$REPLY"'
它会将我放入一个提示中,帮助我根据功能分支名称自动生成提交消息。
> bash -l -c 'current_branch="$(git rev-parse --abbrev-ref HEAD)" && no_feature=${current_branch##*/} && no_underscore=${no_feature%%_*} && history -s "git commit -m \"$no_underscore | " && echo "Press UP to start commit command:" && echo "" && read -e -p "> " && eval "$REPLY"'
Press UP to start commit command:
>
但是如果我把它变成git别名,脚本就会出错。
auto-message = !bash -l -c 'current_branch="$(git rev-parse --abbrev-ref HEAD)" && no_feature=${current_branch##*/} && no_underscore=${no_feature%%_*} && history -s "git commit -m \"$no_underscore | " && echo "Press UP to start commit command:" && echo "" && read -e -p "> " && eval "$REPLY"'
> git auto-message
bash -l -c 'current_branch=$(git rev-parse --abbrev-ref HEAD) && no_feature=${current_branch: -c: line 0: unexpected EOF while looking for matching `''
bash -l -c 'current_branch=$(git rev-parse --abbrev-ref HEAD) && no_feature=${current_branch: -c: line 1: syntax error: unexpected end of file