a bookmarklet to generate the branch name from an open pivotal tracker story

Updated . Posted . Visible to the public.
javascript: (function ($) {
  var storyTitles = [];
  var story = $('.story .details').closest('.story').first();
  if(story){
    var title = story.find('.editor.name').val();
    var id = /story_(\d+)/.exec(story.attr('class'))[1];
    var storyType = story.find(".story_type .selection").text();
    var gitptTitle = id + '-' + title;
    var translate = {
      "ä": "ae", "ö": "oe", "ü": "ue", "ß": "ss"
    };
    var cleanedTitle = storyType + "/" + gitptTitle.toLowerCase().replace(/[öäüß]/g, function(match) { 
      return translate[match]; 
    }).replace(/[^a-zA-Z0-9]+/g, "-").replace(/^-/, "").replace(/-$/, "");
    prompt('Your branch name:', cleanedTitle);
  } else {
    alert("Please select the stories first.");
  }
})(jQuery);
Christoph Beck
Last edit
Tobias Pfeiffer
Posted by Christoph Beck to BitCrowd (2014-03-03 15:20)