#!/bin/bash
# 动作名称输入
printf "Step1:choose your action,intput the option number.\n
you can choose 新增(1)/修改(2)/删除(3)\n
"
echo -e "please input the right number: \c"
read actionNum

case $actionNum in
    1)  #echo '你选择了 1' 
    actionName="新增"
    ;;
    2)  #echo '你选择了 2'
    actionName="修改"
    ;;
    3)  #echo '你选择了 3'
    actionName="删除"
    ;;
    *)  
    echo -e "\033[31m error:  请选择1、2、3当中的某个数字! \e"
    exit 0
    ;;
esac

# 功能名称输入
echo -e "Step2:please input your function name: \c"
read functionName
if test -z $functionName
then
    echo -e "\033[31m error:  功能名称不可为空 \e"
    exit 0
fi

# 功能描述
echo -e "Step3:please input your function description: \c"
read functionDesc
if test -z $functionDesc
then
    echo -e "\033[31m error:  功能描述不可为空 \e"
    exit 0
fi

# 拼接前面的输入
str_commit_msg="$actionName|$functionName|$functionDesc"
git commit -m $str_commit_msg

如果通过脚本从命令终端输入的commit msg中文在git log显示时乱码,可以作如下设置:

git config --global core.quotepath false
git config --global gui.encoding utf-8
git config --global i18n.commit.encoding utf-8
git config --global i18n.logoutputencoding utf-8

0 条评论

发表回复

您的电子邮箱地址不会被公开。