Github - Open PR CheckList

check the base branch, reviews, and field updates

目前為 2022-12-11 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Github - Open PR CheckList
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @description check the base branch, reviews, and field updates
  6. // @author You
  7. // @match https://github.com/*/pull/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=github.com
  9. // @grant none
  10. // @license MIT
  11. // @require http://code.jquery.com/jquery-3.5.1.min.js
  12. // ==/UserScript==
  13. /* globals jQuery, $, waitForKeyElements */
  14.  
  15.  
  16. (function () {
  17. 'use strict';
  18. $(document).ready(function () {
  19. function validatePR() {
  20. var pr_target = $("div#partial-discussion-header div.gh-header-meta span.commit-ref:not(.head-ref)");
  21. var pr_status = $("div#partial-discussion-header div.gh-header-meta span.State").attr("title");
  22. var pr_reviews = $('form.js-issue-sidebar-form[aria-label="Select reviewers"] span.css-truncate').text();
  23. var currentUrl = window.location.href;
  24.  
  25. if (currentUrl.indexOf("/pull/") != -1 && pr_status.indexOf("Open") != -1) { // only handle open PRs
  26. var pr_merge_message = $("div#discussion_bucket div.merge-pr.Details.is-merging div.mergeability-details div.merge-message div.select-menu");
  27.  
  28. // always remind to check field updates for backward-compatibility
  29. pr_merge_message.prepend("<div style=\"color:pink;\"><h4>🤨 Did you DELETE/UPDATE api fields?? If so, are the clients ready?</h4></div>");
  30.  
  31. let badBaseBranch = false;
  32. let badReviewers = false;
  33.  
  34. if (pr_target.text() === "master" || pr_target.text() === "main") {
  35. pr_merge_message.prepend("<div style=\"color:orange; \"><h4>⚠️ You are merging into Master/Main branch 😱 🪵 </h4></div>");
  36. badBaseBranch = true;
  37. }
  38.  
  39. if (pr_reviews.indexOf("No reviews") != -1) {
  40. pr_merge_message.prepend("<div style=\"color:orange;\"><h4>⚠️ This PR has no reviewers! 👀 🤔 🔍 </h4></div>");
  41. badReviewers = true;
  42. }
  43. let alertMessage = '';
  44. if (badBaseBranch) {
  45. alertMessage = 'merging to MAIN?! 😱 🪵';
  46. }
  47. if (badReviewers) {
  48. alertMessage += ' no reviewers!? 👀 🤔 🔍'
  49. }
  50.  
  51. if (alertMessage.length > 0) {
  52. alert(alertMessage);
  53. }
  54.  
  55.  
  56. }
  57.  
  58. }
  59. setTimeout(validatePR, 2000)
  60.  
  61. });
  62. })();
  63.  
  64.  

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址