git alias for HEAD:refs/for/master

前端 未结 8 2254
予麋鹿
予麋鹿 2020-12-02 09:18

I am configuring Gerrit and I would like to avoid writing:

git push gerrit HEAD:refs/for/master

I would like to write:

8条回答
  •  感动是毒
    2020-12-02 09:32

    Hi just create a simple script to automate the process:

       #!/bin/bash
    
       GROUP1_REVIEWER="group1 list of mail separated by space"
       GROUP2_REVIEWER="group2 list of mail separated by space"
       GROUP3_REVIEWER="group3 list of mail separated by space"
    
       ORIGIN=$(git config --get remote.origin.url)
       [ $? -ne 0 ] && echo "Git repo not found; EXIT" && exit 1
    
       case $1 in
           group1) REVIEWER_LIST=$GROUP1_REVIEWER ;;
           group2) REVIEWER_LIST=$GROUP2_REVIEWER ;;
           group3) REVIEWER_LIST=$GROUP3_REVIEWER ;;
           *) echo "Please specify one existent group"; exit 1 ;;
       esac
    
       [ "$1" == "" ] && echo "Please specify one existent group" && exit 1
    
       pushurl=${ORIGIN}
       push="HEAD:refs/for/master"
       receivepack="$(printf "git receive-pack "; for reviewer in $REVIEWER_LIST ; do printf -- "--reviewer $reviewer "; done)"
    
       # check if review remote is already present
       git config -l | grep remote.review 1>/dev/null 2>&1
       [ $? -eq 0 ] && echo "Remote review already present; configure it manually; EXIT" && exit 1
    
       # start config
       echo "Adding new remote review config"
       git config remote.review.pushurl $pushurl
       git config remote.review.push $push
       git config remote.review.receivepack "$receivepack"
    

    You will the use as:

    git_review_add_config.sh group1
    

    And select the different group you need to configure.

提交回复
热议问题