Skip to content

Instantly share code, notes, and snippets.

@caseywatts
Last active June 10, 2017 17:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save caseywatts/1f6f8346a31f937246b4 to your computer and use it in GitHub Desktop.
Save caseywatts/1f6f8346a31f937246b4 to your computer and use it in GitHub Desktop.
Slugify Pivotal Ticket Name (for git branch name)

Short link to this page: http://caseywatts.com/slugify

Other gists & tricks: http://caseywatts.com/gists-and-tricks

Slugify for Pivotal

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