Code Review

We use https://codereview.appspot.com/ for code reviews.

Basic usage:

# checkout, make edits, commit

# update and rebase as needed
git fetch origin
git rebase -i origin/master

# get the baseline commit sha-id's
#
# If you only have one commit, this is trivial:
# E.g. if we want change X, and `git reflog` says:
#   b54ef0b HEAD@{1}: commit: X
#   1ca1304 HEAD@{2}: checkout: moving from master to 1ca1304
# then we want:
#   rev=1ca1304..b54ef0b
#
# If you have multiple pending commits, this is a bit more tricky.
# E.g. if we want change A, and `git reflog` says:
#   d1a08bb HEAD@{1}: rebase -i (pick): B
#   63b7ef0 HEAD@{2}: rebase -i (pick): A
#   5fc3038 HEAD@{3}: checkout: moving from master to 5fc3038d
#   8d997b8 HEAD@{4}: commit: B
#   1e21cd3 HEAD@{5}: commit: A
# then we want:
#   rev=5fc3038..63b7ef0
# If you want B: run `git rebase -i` and move B to the top, which
# will change the reflog to:
#   47cef34 HEAD@{1}: 
rebase -i (finish): returning to refs/heads/master
#   9a0ce1f HEAD@{1}: rebase -i (pick): A
#   a52d24a HEAD@{2}: rebase -i (pick): B
#   5fc3038 HEAD@{3}: checkout: moving from master to 5fc3038d
# (Note: it's not clear if you need to do this for the review, but
#  it's required for the final `git push ...`)
rev=???

# verify diff looks correct

git diff "${rev:-ERROR}"

# get upload script
up=~/bin/upload.py
[[ -e "$up" ]] || {
  mkdir -p $(dirname "$up")
  curl https://codereview.appspot.com/static/upload.py -o "$up" && \
  chmod 755 "$up"; }

# run script w/ above rev
"$up" --rev "$rev"

# when prompted for password, give an application-specific password from:
#   https://accounts.google.com/b/0/IssuedAuthSubTokens#accesscodes

# note printed issue# and URL, e.g.
issue=12345

# go to URL, sign in, then add comments, reviewers, etc
# to notify reviewers, click "Publish+Mail Comments ('m')"

# modify based on reviewer feedback, commit, then:
"$up" --rev "$rev" -i "$issue"

# repeat until approval

# when approved: rebase, change "pick" to "reword", change to commit message:
#   ...
#
#   BUG=
#   R=$reviewer_email
#
#   Review URL: https://codereview.appspot.com/$issue
git fetch origin
git rebase -i origin/master

# get the rebased sha-id from `git reflog`
pushRev=???

# lastly, push to github, either via github pull or:
git push origin "${pushRev:-ERROR}:master"
Comments