#!/bin/bashSCRIPT_NAME=0ドルzprint(){if test x`uname` = x"Darwin"; thenecho -e $@elseecho -e $@fi}vercomp(){# returns: 1ドル > 2ドル: return 0# 2ドル < 1ドル: return 1# 1ドル = 2ドル: return 2echo -e 'test' | grep -- '-e' > /dev/nullnot_suuport_e=$?if [[ $not_support_e = 0 ]]; thenecho "1ドル\n2ドル" | sort --version-sort | head -n1 | grep 2ドル > /dev/nullfirst_larger=$?echo "1ドル\n2ドル" | sort --version-sort | head -n1 | grep 1ドル > /dev/nullsecond_larger=$?elseecho -e "1ドル\n2ドル" | sort --version-sort | head -n1 | grep 2ドル > /dev/nullfirst_larger=$?echo -e "1ドル\n2ドル" | sort --version-sort | head -n1 | grep 1ドル > /dev/nullsecond_larger=$?fiif [[ $first_larger = 0 ]]; thenif [[ $second_larger = 0 ]]; thenreturn 2elsereturn 0fifireturn 1}gitconfig(){bold=$(tput bold)normal=$(tput sgr0)if test x2ドル = x; thenzprint "0円33[33mplease specify sub-command: init|clear|search\n0円33[0m"zprint "search which branches have commits related to ZSTACK-43023: "zprint "0円33[34m./$SCRIPT_NAME.sh git search ZSTACK-43023 0円33[0m"zprint "\nwill fetch remote by default, you can add --no-update to avoid update, like: "zprint "0円33[34m./$SCRIPT_NAME.sh git search ZSTACK-43023 --no-update 0円33[0m"zprint "\ninit git config(commit msg template and hook): just type:"zprint "0円33[34m./$SCRIPT_NAME.sh git init 0円33[0m"zprint "\nclear git config(commit msg template and hook): just type:"zprint "0円33[34m./$SCRIPT_NAME.sh git clear 0円33[0m"exit 1elif test x2ドル = x'search'; thenupdate="y"if test x3ドル = x; thenzprint "0円33[33mplease input commit message you want to search\n0円33[0m"zprint "search which branches have commits related to ZSTACK-43023: "zprint "0円33[34m./runMavenProfile git search ZSTACK-43023 0円33[0m"zprint "\nwill fetch remote by default, you can add --no-update to avoid update, like: "zprint "0円33[34m./runMavenProfile git search ZSTACK-43023 --no-update 0円33[0m"exit 1fiif test x4ドル = x"--no-update"; thenupdate="n"fizprint "============================"if test x$update = x'y'; thenzprint "updating repo zstack-utility ..."timeout 20 git fetch --all > /dev/null 2>&1fizprint "searching in repo zstack-utility ..."zprint "============================"sha1s=`git log --oneline --all --grep "3ドル" | cut -d" " -f1 | tr '\n' ' '`if test x`echo $sha1s|tr -d ' '` = x''; thenzprint "0円33[33mcan not find any related commits in repo zstack-utility0円33[0m"elsezprint "\n0円33[32mfind commits 0円33[34m$sha1s0円33[0mrelated to 0円33[34m3ドル0円33[0m 0円33[0m"for sha1 in $sha1s; dobr=`git branch --remote --contains $sha1 | grep -Eo '/[1-5]\.[0-9]+\.[0-9]+.*' | grep -Eo '[1-5].[0-9]+.[0-9]+.*' | grep -v '/'`zprint "\n0円33[32mrelase branches with commit 0円33[34m$sha10円33[0m:0円33[0m \n${bold}$br${normal}"donefielif test x2ドル = x'init'; theninit_git_configelif test x2ドル = x'clear'; thenclear_git_configelsezprint "0円33[31mnot support ${bold}\"2ドル\"${normal}0円33[31myet0円33[0m"fi}init_git_config() {git config --global commit.verbose truemessage_path=$(git rev-parse --show-toplevel)/.gitconfig/gitmessagehook_dir=$(git rev-parse --show-toplevel)/.gitconfig/hooksif [ ! -f $message_path ]; thenzprint "0円33[33mERROR: can not find git message template at $message_path0円33[0m"fiif [ ! -d $hook_dir ]; thenzprint "0円33[33mERROR: can not find git hook at $hook_dir0円33[0m"ficurr_git_ver=`git version | awk '{print 3ドル}'`vercomp $curr_git_ver 2.9support_config_hook=$?if [ $support_config_hook -eq 1 ]; thenzprint "0円33[33mgit version older than 2.9, would replace git hook in .git rather than config hook path0円33[0m"mv $(git rev-parse --show-toplevel)/.git/hooks/prepare-commit-msg $(git rev-parse --show-toplevel)/.git/hooks/prepare-commit-msg.bak.`date +%s` 2>/dev/nullmv $(git rev-parse --show-toplevel)/.git/hooks/commit-msg $(git rev-parse --show-toplevel)/.git/hooks/commit-msg.bak.`date +%s` 2>/dev/nullcp $(git rev-parse --show-toplevel)/.gitconfig/hooks/* $(git rev-parse --show-toplevel)/.git/hooks/elsezprint "0円33[33mgit version newer than 2.9, would config hook path0円33[0m"git config core.hooksPath $(git rev-parse --show-toplevel)/.gitconfig/hooksfigit config commit.template $(git rev-parse --show-toplevel)/.gitconfig/gitmessagezprint "0円33[32mconfig git commit msg template and hook success!0円33[0m"}clear_git_config() {curr_git_ver=`git version | awk '{print 3ドル}'`vercomp $curr_git_ver 2.9support_config_hook=$?if [ $support_config_hook -eq 1 ]; thenrm $(git rev-parse --show-toplevel)/.git/hooks/prepare-commit-msg 2> /dev/nullrm $(git rev-parse --show-toplevel)/.git/hooks/commit-msg 2> /dev/nullelsegit config --unset core.hooksPathfigit config --unset commit.templatezprint "0円33[32mclear git commit msg template and hook success!0円33[0m"}run_profile() {if test x1ドル = x'git'; thengitconfig $@elseusagefi}usage() {zprint "0円33[33mplease specify sub-command, only support git for now0円33[0m\n"zprint "for example: "zprint "0円33[34m0ドル git0円33[0m"}if [ "$#" -eq 0 ]; thenzprint "0円33[33mno sub-command specified, init git config automatically...0円33[0m\n"run_profile git initexitfiif test x1ドル = x'help'; thenusagefirun_profile $@
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。