Last active
November 1, 2023 14:07
-
-
Save cmcculloh-kr/0f9f454bad4173f91b4231e5b1ae83e1 to your computer and use it in GitHub Desktop.
Bookmarklet for creating Github branch names from JIRA tickets.
This file contains hidden or 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
javascript: (function() { | |
const generateBranchName = () => { | |
const title = document.querySelector("title").innerText; | |
const issueCodeMatch = title.match(/\[(.*)\]/); | |
if (!issueCodeMatch) return; | |
let issueDescription = title.replace(/\[.*]\s/, ""); | |
const parts = issueDescription.split(" - "); | |
issueDescription = parts.slice(0, parts.length - 1).join(" - "); | |
issueDescription = issueDescription.replace(/[^a-zA-Z0-9\s-]/g, ''); | |
issueDescription = issueDescription.replace(/\s+/g, '-').toLowerCase(); | |
issueDescription = issueDescription.replace(/--/g, '---'); | |
const branchName = `${issueCodeMatch[1]}___${issueDescription}`; | |
navigator.clipboard.writeText(branchName); | |
console.log(`${branchName} copied to clipboard!`); | |
}; | |
generateBranchName(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment