Skip to content

Instantly share code, notes, and snippets.

@cmcculloh-kr
Created April 27, 2016 16:25
Show Gist options
  • Save cmcculloh-kr/0e659dc7e0de59c99d75454b2a7dcead to your computer and use it in GitHub Desktop.
Save cmcculloh-kr/0e659dc7e0de59c99d75454b2a7dcead to your computer and use it in GitHub Desktop.
Get branch from JIRA
// This is the expanded code for the bookmarklet.
// Use the minified code for the actual bookmarklet
javascript:(function() {
var title = jQuery('title').text();
var ticket = title.match(/\[(.*)]/);
var title_no_ticket = title.replace(/\[.*]\ /, '');
var title_no_suffix = title_no_ticket.replace(/\ \-\ ExactTarget\ JIRA/, '');
var title_cleaned = title_no_suffix.replace(/ \& /g, '_and_');
title_cleaned = title_cleaned.replace(/\&/g, '/');
title_cleaned = title_cleaned.replace(/,/g, '_');
title_cleaned = title_cleaned.replace(/: /g, '--');
title_cleaned = title_cleaned.replace(/:/g, '--');
title_cleaned = title_cleaned.replace(/ %E2%80%93 /g, '--');
title_cleaned = title_cleaned.replace(/ %E2%80%94 /g, '---');
title_cleaned = title_cleaned.replace(/%E2%80%93/g, '--');
title_cleaned = title_cleaned.replace(/%E2%80%94/g, '---');
title_cleaned = title_cleaned.replace(/\//g, '_or_');
title_cleaned = title_cleaned.replace(/\%/g, '-percent');
title_cleaned = title_cleaned.replace(/\"/g, '');
title_cleaned = title_cleaned.replace(/\'/g, '');
title_cleaned = title_cleaned.replace(/`/g, '');
title_cleaned = title_cleaned.replace(/%E2%80%9C/g, '');
title_cleaned = title_cleaned.replace(/%E2%80%9D/g, '');
title_cleaned = title_cleaned.replace(/%E2%80%98/g, '');
title_cleaned = title_cleaned.replace(/%E2%80%99/g, '');
title_cleaned = title_cleaned.replace(/\(/g, '');
title_cleaned = title_cleaned.replace(/\)/g, '');
title_cleaned = title_cleaned.replace(/\{/g, '');
title_cleaned = title_cleaned.replace(/\}/g, '');
title_cleaned = title_cleaned.replace(/\[/g, '');
title_cleaned = title_cleaned.replace(/\]/g, '');
title_cleaned = title_cleaned.replace(/@/g, '');
title_cleaned = title_cleaned.replace(/\$/g, '');
title_cleaned = title_cleaned.replace(/\*/g, '');
title_cleaned = title_cleaned.replace(/\#/g, '');
title_cleaned = title_cleaned.replace(/\!/g, '');
var title_no_spaces = title_cleaned.replace(/\ /g, '-')
var title_lower = title_no_spaces.toLowerCase();
var branch_name = ticket[1] + '___' + title_lower;
function copyToClipboard(text) { window.prompt("Copy:", text);}
copyToClipboard(branch_name);
branch_name;
})();
javascript:(function(){function e(e){window.prompt("Copy:",e)}var r=jQuery("title").text(),a=r.match(/\[(.*)]/),c=r.replace(/\[.*]\ /,""),p=c.replace(/\ \-\ ExactTarget\ JIRA/,""),l=p.replace(/ \& /g,"_and_");l=l.replace(/\&/g,"/"),l=l.replace(/,/g,"_"),l=l.replace(/: /g,"--"),l=l.replace(/:/g,"--"),l=l.replace(/ – /g,"--"),l=l.replace(/ — /g,"---"),l=l.replace(/–/g,"--"),l=l.replace(/—/g,"---"),l=l.replace(/\//g,"_or_"),l=l.replace(/\%/g,"-percent"),l=l.replace(/\"/g,""),l=l.replace(/\'/g,""),l=l.replace(/`/g,""),l=l.replace(/“/g,""),l=l.replace(/”/g,""),l=l.replace(/‘/g,""),l=l.replace(/’/g,""),l=l.replace(/\(/g,""),l=l.replace(/\)/g,""),l=l.replace(/\{/g,""),l=l.replace(/\}/g,""),l=l.replace(/\[/g,""),l=l.replace(/\]/g,""),l=l.replace(/@/g,""),l=l.replace(/\$/g,""),l=l.replace(/\*/g,""),l=l.replace(/\#/g,""),l=l.replace(/\!/g,"");var g=l.replace(/\ /g,"-"),t=g.toLowerCase(),E=a[1]+"___"+t;e(E)})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment