Created
January 20, 2022 02:20
-
-
Save RolandWarburton/59df7b409aa09ac5020bbec811c42e26 to your computer and use it in GitHub Desktop.
Grease Monkey bookmarklet to never miss a badly named jira PR again
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name PR ticket name checker | |
// @author Roland Warburton | |
// @version 1.1 | |
// @grant none | |
// @match https://github.com/REPLACEME/*/pull/* | |
// ==/UserScript== | |
// README | |
// 1. Update the @match rule for your organization | |
// 2. Update the prTicketName with your organizations ticket format | |
// 3. Install grease monkey and create a new script | |
// README | |
// UPDATE ME WITH YOUR TICKET FORMAT | |
const prTicketName = "ABCD-[0-9][0-9][0-9][0-9].*" | |
const dPrTitle = document.querySelector(".js-issue-title"); | |
const prTitleContent = dPrTitle.textContent | |
const prTitleRegExp = new RegExp(prTicketName); | |
const prTitleIsCorrect = prTitleRegExp.test(prTitleContent); | |
const dErrorBox = document.createElement("div"); | |
dErrorBox.textContent = "Check PR name"; | |
dErrorBox.style.backgroundColor = "red"; | |
dErrorBox.style.color = "black"; | |
dErrorBox.style.display = "inline"; | |
dErrorBox.style.padding = "5px"; | |
if (!prTitleRegExp.test(prTitleContent)) { | |
dPrTitle.parentElement.append(dErrorBox); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment