使用Gerrit时Push当前分支到Gerrit

从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'"

你可能感兴趣的:(git,gerrit)