Last active
August 29, 2015 14:25
-
-
Save chris-erickson/42fa19840db34cdcaf02 to your computer and use it in GitHub Desktop.
Something dumb to make getting JIRA branchnames faster.
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
var selectedIssue = document.querySelectorAll(".ghx-selected")[0]; | |
var key = selectedIssue.dataset.issueKey; | |
var description = selectedIssue.childNodes[0].childNodes[0].childNodes[2].title; | |
var text = key + '-' + description; | |
var MAX_LENGTH = 35; | |
var slug = text.replace(/\s+/g, '-').replace(/[^\w\-]+/g, '').replace(/\-\-+/g, '-').replace(/^-+/, '').replace(/-+$/, '').substring(0, MAX_LENGTH); | |
window.prompt("Copy this!", 'git checkout -b \'' + slug + '\''); |
Text expander variant:
var MAX_LENGTH = 35;
// Ask for the string to slugify
var text = "%filltext:name=Human name:default=Just type it in, we'll do the rest!:width=45%";
// Strip the text and output it
text.replace(/\s+/g, '-').replace(/[^\w\-]+/g, '').replace(/\-\-+/g, '-').replace(/^-+/, '').replace(/-+$/, '').substring(0, MAX_LENGTH);
// %filltop%
I bind this to ;bn. Note that it doesn't add in the checkout command because I usually have that already added when I realize I need a branch name.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Something to help make the bookmarklet.