Changeset View
Changeset View
Standalone View
Standalone View
tools/tools/git/git-arc.sh
| Show First 20 Lines • Show All 228 Lines • ▼ Show 20 Lines | elif [ "$(echo "$diff" | wc -l)" -ne 1 ]; then | ||||
| err "found multiple reviews with the same title" | err "found multiple reviews with the same title" | ||||
| fi | fi | ||||
| echo "$diff" | echo "$diff" | ||||
| } | } | ||||
| create_one_review() | create_one_review() | ||||
| { | { | ||||
| local childphid commit doprompt msg parent parentphid reviewers | local childphid commit doprompt draft msg parent parentphid reviewers | ||||
| local subscribers | local subscribers | ||||
| commit=$1 | commit=$1 | ||||
| reviewers=$2 | reviewers=$2 | ||||
| subscribers=$3 | subscribers=$3 | ||||
| parent=$4 | parent=$4 | ||||
| doprompt=$5 | doprompt=$5 | ||||
| draft=$6 | |||||
| if [ "$doprompt" ] && ! show_and_prompt "$commit"; then | if [ "$doprompt" ] && ! show_and_prompt "$commit"; then | ||||
| return 1 | return 1 | ||||
| fi | fi | ||||
| if [ "$draft" -eq 1 ]; then | |||||
| draft=--draft | |||||
| else | |||||
| unset draft | |||||
| fi | |||||
| msg=$(xmktemp) | msg=$(xmktemp) | ||||
| git show -s --format='%B' "$commit" > "$msg" | git show -s --format='%B' "$commit" > "$msg" | ||||
| printf "\nTest Plan:\n" >> "$msg" | printf "\nTest Plan:\n" >> "$msg" | ||||
| printf "\nReviewers:\n" >> "$msg" | printf "\nReviewers:\n" >> "$msg" | ||||
| printf "%s\n" "${reviewers}" >> "$msg" | printf "%s\n" "${reviewers}" >> "$msg" | ||||
| printf "\nSubscribers:\n" >> "$msg" | printf "\nSubscribers:\n" >> "$msg" | ||||
| printf "%s\n" "${subscribers}" >> "$msg" | printf "%s\n" "${subscribers}" >> "$msg" | ||||
| yes | EDITOR=true \ | yes | EDITOR=true \ | ||||
| arc diff --message-file "$msg" --never-apply-patches --create \ | arc diff --message-file "$msg" --never-apply-patches --create \ | ||||
| --allow-untracked $BROWSE --head "$commit" "${commit}~" | --allow-untracked $draft $BROWSE --head "$commit" "${commit}~" | ||||
| [ $? -eq 0 ] || err "could not create Phabricator diff" | [ $? -eq 0 ] || err "could not create Phabricator diff" | ||||
| if [ -n "$parent" ]; then | if [ -n "$parent" ]; then | ||||
| diff=$(commit2diff "$commit") | diff=$(commit2diff "$commit") | ||||
| [ -n "$diff" ] || err "failed to look up review ID for $commit" | [ -n "$diff" ] || err "failed to look up review ID for $commit" | ||||
| childphid=$(diff2phid "$diff") | childphid=$(diff2phid "$diff") | ||||
| parentphid=$(diff2phid "$parent") | parentphid=$(diff2phid "$parent") | ||||
| ▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | for chash in "$@"; do | ||||
| [ -n "$_commits" ] || err "invalid commit ID ${chash}" | [ -n "$_commits" ] || err "invalid commit ID ${chash}" | ||||
| commits="$commits $_commits" | commits="$commits $_commits" | ||||
| done | done | ||||
| echo "$commits" | echo "$commits" | ||||
| } | } | ||||
| gitarc__create() | gitarc__create() | ||||
| { | { | ||||
| local commit commits doprompt list o prev reviewers subscribers | local commit commits doprompt draft list o prev reviewers subscribers | ||||
| list= | list= | ||||
| prev="" | prev="" | ||||
| if get_bool_config arc.list false; then | if get_bool_config arc.list false; then | ||||
| list=1 | list=1 | ||||
| fi | fi | ||||
| doprompt=1 | doprompt=1 | ||||
| while getopts lp:r:s: o; do | draft=0 | ||||
| while getopts dlp:r:s: o; do | |||||
| case "$o" in | case "$o" in | ||||
| d) | |||||
| draft=1 | |||||
| ;; | |||||
| l) | l) | ||||
| list=1 | list=1 | ||||
| ;; | ;; | ||||
| p) | p) | ||||
| prev="$OPTARG" | prev="$OPTARG" | ||||
| ;; | ;; | ||||
| r) | r) | ||||
| reviewers="$OPTARG" | reviewers="$OPTARG" | ||||
| Show All 17 Lines | if [ "$list" ]; then | ||||
| if ! prompt; then | if ! prompt; then | ||||
| return | return | ||||
| fi | fi | ||||
| doprompt= | doprompt= | ||||
| fi | fi | ||||
| for commit in ${commits}; do | for commit in ${commits}; do | ||||
| if create_one_review "$commit" "$reviewers" "$subscribers" "$prev" \ | if create_one_review "$commit" "$reviewers" "$subscribers" "$prev" \ | ||||
| "$doprompt"; then | "$doprompt" "$draft"; then | ||||
| prev=$(commit2diff "$commit") | prev=$(commit2diff "$commit") | ||||
| else | else | ||||
| prev="" | prev="" | ||||
| fi | fi | ||||
| done | done | ||||
| } | } | ||||
| gitarc__list() | gitarc__list() | ||||
| ▲ Show 20 Lines • Show All 447 Lines • Show Last 20 Lines | |||||