Skip to content

Instantly share code, notes, and snippets.

@chris-erickson
Last active August 29, 2015 14:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chris-erickson/42fa19840db34cdcaf02 to your computer and use it in GitHub Desktop.
Save chris-erickson/42fa19840db34cdcaf02 to your computer and use it in GitHub Desktop.
Something dumb to make getting JIRA branchnames faster.
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 + '\'');
@chris-erickson
Copy link
Author

Something to help make the bookmarklet.

@chris-erickson
Copy link
Author

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