Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add git-review approve which approves the checked out change,patch bu…

…t does not merge it.
  • Loading branch information...
commit 374a37d4874f66fd42acc8bbbb60694fb2b1475d 1 parent 2f5e491
Brian Donovan authored
Showing with 26 additions and 0 deletions.
  1. +26 −0 bin/git-review
View
26 bin/git-review
@@ -124,6 +124,9 @@ printUsage() {
echo " update"
echo " Updates the review branch that you're currently on to the latest patch."
echo
+ echo " approve"
+ echo " Approves the current patch but does not merge it."
+ echo
echo " reset"
echo " Removes the current change branch created by the 'start' subcommand and switches"
echo " back to master."
@@ -240,6 +243,25 @@ resetReview() {
die "Unable to close the review branch $CURRENT"
}
+approveChange() {
+ local url_line=$($GIT remote show -n changes | grep "URL: " | head -n1)
+ local host_and_project=${url_line# *URL: }
+ local host=${host_and_project%:*}
+ local project=${host_and_project#*:}
+
+ get_change_number_from_branch ||
+ die "Unable to get change number from $CURRENT"
+ local PATCH=$(patch_count_for_change $CHANGE)
+
+ local LOG=$($GIT log --pretty="format:%s" origin/master..HEAD)
+ good "Approving '$LOG'..."
+ ssh $host gerrit approve \
+ --verified=+1 \
+ --code-review=+2 \
+ --project=$project $CHANGE,$PATCH ||
+ die "Unable to approve the commit"
+}
+
diffPatches() {
local change=$1
local patch1=$2
@@ -386,6 +408,10 @@ while true; do
rebaseReview $1
exit
;;
+ approve)
+ approveChange
+ exit
+ ;;
update)
updateReview
exit
Please sign in to comment.
Something went wrong with that request. Please try again.