a bookmarklet to generate the commit message from an open pivotal tracker story

Posted About 10 years ago. Visible to the public.
javascript: (function ($) {
    var storyTitles = [];
    var stories = $('div.story .selector.selected').closest('.story');
    var collapsed = true;
    if (stories.length == 0) {
        stories = $('div.story .details').closest('.story');
        collapsed = false;
    }
    stories.each(function () {
        var story = $(this);
        var title = (collapsed ? story.find('.story_name').text() : story.find('.editor.name').val());
        var id = /story_(\d+)/.exec(story.attr('class'))[1];
        var gitptTitle = '[#' + id + '] ' + title;
        if (storyTitles.indexOf(gitptTitle) == -1) {
            storyTitles.push(gitptTitle);
        }
    });
    if (storyTitles.length > 0) {
        prompt('Your commit message:', storyTitles.join('; '));
    } else {
        alert("Please select the stories first.");
    }
})(jQuery);
Christoph Beck
Last edit
About 10 years ago
Posted by Christoph Beck to BitCrowd (2014-03-03 15:20)