Skip to content

Instantly share code, notes, and snippets.

@mercuryrain
Created April 11, 2012 10:10
Show Gist options
  • Save mercuryrain/2358371 to your computer and use it in GitHub Desktop.
Save mercuryrain/2358371 to your computer and use it in GitHub Desktop.
Bookmarklet to get branch name (original)
(function($,window,undefined){
var key = $("#key-val").text(),
descr = $("h1").text(),
errors = "",
sprintLabels = $.grep(jQuery("ul.labels li"),function(el){
return $(el).text().match(/sprint/);
});
if(!key.length) errors += "Key is not defined\n";
if(!descr.length) errors += "Description is not defined\n";
if(!sprintLabels.length) errors += "Sprint label is not defined\n";
if(errors.length){
alert(errors);
return;
}
var sprint = $(sprintLabels[0]).text(),
branchName = sprint+'_UA_'+key+'_'+descr.toLowerCase().replace(/\(\)/g,'').replace(/\W/g,'_').replace(/_+/g,'_').replace(/_$/g,'');
window.prompt("Branch name:\n" + branchName + "\n" + "Create branch:\ngit checkout -b " + branchName , branchName );
})(jQuery,window);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment