Git post-receive hook that submits code to Review Board for post-review

Took a bit of fiddling to figure this out from the various docs.

  1. Create a checkout of the repo owned by the git user, e.g. ~git/myrepo, and git config reviewboard.url http://XXX
  2. Create a shell script, submit-post-review.sh owned by the git user that does
    #!/bin/bash
    cd ~git/myrepo
    unset GIT_DIR
    git pull
    HOME=~git post-review --guess-summary --guess-description --target-groups=Everyone --publish --username=git --password=XX --revision-range=$1:$2
    
  3. In /myrepo.git/hooks/post-receive, add
    while read oldrev newrev refname; do
      if [ $refname = "refs/head/master" ]; then
        ~git/submit_code_review.sh $oldrev $newrev
      fi
    done
    

I still haven’t worked out how to get —submit-as to map correctly, though, and I’d love to know if there’s a way to simplify this!

blog comments powered by Disqus

Notes

  1. codeshal posted this