Skip to content

This is a TamperMonkey script that hides all files of the Pull Requests whose relative path start with a given prefix.

Notifications You must be signed in to change notification settings

halmai/github-hider

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 

Repository files navigation

github-hider

This is a TamperMonkey script that hides all files of the Pull Requests or a Commit whose relative path matches a given regular expression. For example, you can hide all the files of a PR which are under the vendor/ directory or the ones that are generated from protobuf files (match \.pb\.go$). The toggle button unhides all if you still want to see them.

Usage example

Install

  1. Install TamperMonkey for Firefox or Chrome: https://www.tampermonkey.net/. (TamperMonkey is a browser addon which makes it possible to excute your own JavaScript code when a web page is downloaded from a remote server.)
  2. Click the icon of the add-on (TamperMonkey Logo) on the toolbar
  3. Click "Create a New Script"
  4. Copy-Paste the content of userscript.js in place of the original boilerplate code
  5. Skim the code in order to ensure it doesn't do anything nasty ;)
  6. Modify the @match lines at the top of the file accordingly if you use not just github.com but a domain name like github.<yourcompany>.com too. (The @match lines limit in case of wich URLs the script needs to run.)
  7. Modify the constants patternToHide and frequencyOfDeleteMillisec according to your needs. (In most cases you don't need to change them.)
  8. Save the script by File -> Save
  9. Close this tab
  10. Open a new tab where the files of a Pull Request can be browsed.

Why?

In some cases, it's better to add generated files and dependencies to the git repository. For example, it makes the installation significantly faster, which is very important in CI/CD environments.

In such cases, you may have a huge vendor/ directory with hundreds of files. If these files are changing for some reason then your PR will look as if you edited a lot of files which is just partly true. Indeed, those files have been changed but those changes are not something that you want to investigate. Probably, you don't want to see those many file changes and don't want to confuse your peers either.

In such cases, it is nice to hide all the files under the vendor/ directory.

How does it work?

Because github fetches the files of a Pull Request or a Commit in smaller chunks, a TamperMonkey script cannot be run "after" them. It is better to hide the files as early as possible. If newer files are displayed, the TamperMonkey script hides those ones as well. In order to do this, it runs in every second.

The code runs for less than 5 milliseconds on a decent developer laptop so it shouldn't be an issue if it runs in every second.

TODO

  1. Investigate whether it is possible to stop the repeated hiding operation after a certain point.

About

This is a TamperMonkey script that hides all files of the Pull Requests whose relative path start with a given prefix.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published