使用Gerrit时Push当前分支到Gerrit

  • Post author:
  • Post category:其他


从Github上找到一段非常方便的可以推送当前分支并添加reviewer的alias

push-gerrit = "!bash -c ' \
            local_ref=$(git symbolic-ref HEAD); \
            local_name=${local_ref##refs/heads/}; \
            remote=$(git config branch.\"$local_name\".remote || echo origin); \
            remote_ref=$(git config branch.\"$local_name\".merge); \
            remote_name=${remote_ref##refs/heads/}; \
            remote_review_ref=\"refs/for/$remote_name\"; \
            r=\"\"; \
            if [[ $0 != \"\" && $0 != \"bash\" ]]; then r=\"--reviewer=$0\"; fi; \
            if [[ $1 != \"\" ]]; then r=\"$r --reviewer=$1\"; fi; \
            if [[ $2 != \"\" ]]; then r=\"$r --reviewer=$2\"; fi; \
            if [[ $3 != \"\" ]]; then r=\"$r --reviewer=$3\"; fi; \
            if [[ $4 != \"\" ]]; then r=\"$r --reviewer=$4\"; fi; \
            git push --receive-pack=\"gerrit receive-pack $r\" $remote HEAD:$remote_review_ref'"



版权声明:本文为zycdsg原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。