GitHubFlow PR merge idiot-proofing

Confirmation before common mistakes when merging Pull Requests in github

  1. // ==UserScript==
  2. // @name GitHubFlow PR merge idiot-proofing
  3. // @namespace https://gist.github.com/raveren/f08ba2673a92c582692e1a233621762f
  4. // @version 0.3
  5. // @author raveren
  6. // @description Confirmation before common mistakes when merging Pull Requests in github
  7. // @match https://github.com/*/pull/*
  8. // ==/UserScript==
  9.  
  10. (function() {
  11. document.querySelector('.js-merge-branch-action').addEventListener('click', function(e){
  12. if ( document.querySelector('#commits_tab_counter').innerHTML.trim()!='1'
  13. && !confirm('More than one commit, you still wanna merge?')) {
  14. e.preventDefault();
  15. e.stopPropagation();
  16. return false;
  17. }
  18. if ( document.querySelector('.text-pending') && !confirm('Build not complete yet, you still wanna merge?')) {
  19. e.preventDefault();
  20. e.stopPropagation();
  21. return false;
  22. }
  23. });
  24. })();