(Updated: )
/ #javascript #github 

Github Pull Request Review: reset viewed files

GitHub Pull Request Review workflow is great.

What I particularly like is the “file viewed” toggle, which mean that I’m not tempted to re-review the whole Pull Request when a single file has changed and I’ve already checked the rest of them.

However there are instances where I want to re-review the PR as a whole instead of just the changes since my last review. For example when there have been a lot of small changes that add up.

I’ve used the following snippet in the “files” Pull Request Review View (/pulls/{id}/files) to reset the “viewed” files (if they’re all marked as viewed).

Mark all files in a GitHub PR as “not viewed”:

document.querySelectorAll('.js-reviewed-toggle').forEach(c => c.click())

— Hugo (@hugo__df) June 1, 2020

A smarter way to do this is to uncheck all the checked js-reviewed-checkbox elements on the page:

Unmark all “viewed” files in a GitHub PR:

document.querySelectorAll('.js-reviewed-checkbox[checked]').forEach(c => c.click())

— Hugo (@hugo__df) July 7, 2020

You can add this to your own browser as a bookmarklet

  1. Right click on this link: GH Review > Mark all unviewed
  2. Select “Bookmark this link” or equivalent
  3. Save it as a bookmark
  4. You can now use the “GH Review > Mark all unviewed” bookmarklet on the GitHub Review page

Photo by Markus Winkler on Unsplash

Author

Hugo Di Francesco

Co-author of "Professional JavaScript", "Front-End Development Projects with Vue.js" with Packt, "The Jest Handbook" (self-published). Hugo runs the Code with Hugo website helping over 100,000 developers every month and holds an MEng in Mathematical Computation from University College London (UCL). He has used JavaScript extensively to create scalable and performant platforms at companies such as Canon, Elsevier and (currently) Eurostar.

Get The Jest Handbook (100 pages)

Take your JavaScript testing to the next level by learning the ins and outs of Jest, the top JavaScript testing library.