Pages

Friday, August 24, 2012

Git + Code Collaborator: Post Checkin Code Review

Sometimes you submit your code before you setup a review with code collaborator.  Here are a couple ways to create a code review with code collaborator for git checkins.  I will cover the standard cases, before you stage the code, once the code has been staged for commit, and after you have submitted the code.

With Unstaged Changes

This one is easy, nothing special needed.
git status 
# On branch master 
# Changes not staged for commit: 
#   (use "git add ..." to update what will be committed) 
#   (use "git checkout -- ..." to discard changes in working directory) 
# 
# modified:   changedFile.m 
# 
Now run the command to add a diff of the modified files:
ccollab addgitdiffs new

With Staged Changes

This is not very tricky, but you do need to give the git diff option for staged files, --cached.

git status 
# On branch master 
# Changes to be committed: 
#   (use "git reset HEAD ..." to unstage) 
# 
# modified:   changedFile.m
 Now run the command to add a diff of the cached/staged files:
ccollab addgitdiffs new --cached

With Committed Changes

This one is more tricky.  You have committed the files.  Let's use reflag to see the commits.  Then take the SHA1 hash of the commit you want to diff and the previous commit do a diff between commits.

git status 
# On branch master 
nothing to commit (working directory clean)


As you see, git status will not show any changes since you committer your work.

git reflog
aa90bc4 HEAD@{0}: commit: Changes I forgot to code review.
bb37e6c HEAD@{1}: commit: Some other changes
......

Now use the SHA1 hash of each commit to make your diff:

ccollab addgitdiffs new bb37e6c aa90bc4
Now you should have a code review with the difference between your changes and the previous commit.

Hope that helps

No comments:

Post a Comment