GitHub added this feature, along with many other excellent code review tools!
GitHub's pull requests are fine for code review most of the time, but can get messy for long-lived PRs where there are lots of commits touching lots of files, but the new commits are making relatively small changes. It's possible to add comments to individual commits, but this still has the problems that a) the commit comments show up differently to regular PR diff comments and b) sometimes a range of commits have been added to be reviewed, and reviewing them one-by-one can be tedious.
Gitique enables the files tab of a GitHub PR to be restricted to only a set of the most recent commits. By default, it chooses all commits since the last comment by a reviewer (anyone who's not the author).
The gif below shows what happens with a demo PR: some changes were made, a
reviewer made a comment, and the author added a commit. Choosing to view only the latest
changes hides all changes in .gitignore
(as the last commit didn't touch that file) and
shows only the relevant changes from the latest commit in green (so line 3 of the README
is no longer marked as a new line).
For more on this subject, see improving GitHub code review.
Once installed, Gitique runs on every GitHub page. When it detects that you're on a pull request, it looks at the discussion. Any commits made after the last comment by someone who is not the author will have a green icon next to them. Those commits will have their contents kept visible when Gitique is enabled, while the contents of other commits will be hidden.
The actual change in behaviour is on the files tab, where Gitique adds a button to view only the changes from the selected commits. Any changes for the overall diff which are not included in the restricted diff will be hidden.
To change the commits Gitique uses, click on the icon next to a commit SHA. This will set the commit as the base commit for the comparison. (This commit's contents will not be included in the Gitique view, but all commits following it will be.)
- - a commit that is not the HEAD, when there are no review comments.
- - a reviewed commit. If there are comments by reviewers (people not the author of the pull request), all but the last commit before the last review comment will have this colour. Diffs from these commits are not shown when the Gitique view is enabled.
- - the base commit. This takes the place of the HEAD of the target branch when the Gitique view is enabled, so its diff is not shown. By default, it is the last commit before the last review comment.
- - a new commit. All but the last commit after the last reviewer comment are shown in this colour by default, and their diffs are maintained when the Gitique view is enabled.
- - the HEAD of the selected branch in this PR. This diff will always be shown when the Gitique view is enabled, and this is the only commit which cannot be selected as the base commit.
- Clone this repo.
- From the root of the cloned repo, run
make
. This will download the ClojureScript compiler and run it on the source, producing the filegitique.js
. This script will watch for changes in the source. - This depends on the browser.
- Chrome: go to chrome://extensions/ and choose to load an
unpacked extension, then point to the
src/chrome
directory in the cloned repo. - Firefox: install
jpm
(npm install -g jpm
) first, then fromsrc/firefox
dojpm run
and use the blank profile that generates. Alternatively, runjpm xpi
and then choose to install an add-on from a file at about:addons.
- Chrome: go to chrome://extensions/ and choose to load an
unpacked extension, then point to the
- To run the unit tests, run
make test
. This requires PhantomJS version 2 to be on the path asphantomjs
. It will watch thetest
andsrc
directories and run the tests on the built output.make ci
will compile, run the tests, and exit without watching. - To run the Webdriver tests, install boot and run
make selenium
. This will run some basic tests against the gitique-examples repo in Chrome and Firefox. A production build is needed for these, as the generated XPI is loaded by Firefox for the tests.
- Update
dist/chrome/manifest.json
anddist/firefox/package.json
for the new version. - Run
make release
. This will build using advanced optimizations, then packagedist/chrome
intodist/chrome.zip
, anddist/firefox
intodist/firefox/@gitique-$version.xpi
.