Skip to content

Instantly share code, notes, and snippets.

@RolandWarburton
Created January 20, 2022 02:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RolandWarburton/59df7b409aa09ac5020bbec811c42e26 to your computer and use it in GitHub Desktop.
Save RolandWarburton/59df7b409aa09ac5020bbec811c42e26 to your computer and use it in GitHub Desktop.
Grease Monkey bookmarklet to never miss a badly named jira PR again
// ==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