Create a gist now

Instantly share code, notes, and snippets.

Slugify Pivotal Ticket Name (for git branch name)

Link: http://caseywatts.com/slugify

For a given pivotal card that's open, create an appropriate github branch name for it - including the id and ticket title.

How To Use

This code is used as a javascript bookmarklet. It is a bookmark in your browser that executes some javascript code, instead of navigating you to a new page.

  1. Copy the code block in slugit.js
  2. Create a new bookmark, maybe on your Bookmarks Bar for quick access.
  3. Name it something (like slugit)
  4. Paste the code block into Location (or URL).
  5. While on PivotalTracker with a card open, click the bookmark. If there are multiple cards open, this will read from the first one jQuery finds (probably the top left one).
javascript:(function(){
function slugify(text) {
return text.toString().toLowerCase()
.replace(/\s+/g, '-')
.replace(/[^\w\-]+/g, '')
.replace(/\-\-+/g, '-')
.replace(/^-+/, '')
.replace(/-+$/, '');
}
try{
id = $('.edit.details').find('input.id')[0].value;
ticket_title = $('.edit.details').find('[name="story[name]"]')[0].innerHTML;
slug = slugify(id + "-" + ticket_title);
prompt("Here is your slugified title for the first opened pivotal card.", slug);
}
catch(e){
alert("You are not on a pivotal page with a ticket open.");
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment