Skip to content

Instantly share code, notes, and snippets.

@salarmehr
Last active June 18, 2020 01:40
Show Gist options
  • Save salarmehr/e907677852342bcf16a675fe9a8e294b to your computer and use it in GitHub Desktop.
Save salarmehr/e907677852342bcf16a675fe9a8e294b to your computer and use it in GitHub Desktop.
// while Jira has a create branch botton, it take some seconds to create a branch and use it locally
// it's quicker to generate the git command and run it locally.
// run in in console or create a brower bookmark prefixing it with `javascript:` and copy this gist as url.
// now you can click on the bookmakr button ot copy the git command to clipboard.
function copy(text) {
var input = document.createElement('input');
input.setAttribute('value', text);
document.body.appendChild(input);
input.select();
var result = document.execCommand('copy');
document.body.removeChild(input);
return result;
}
var type = jQuery('[src$=issuetype]').length ? 'feature' : 'bugfix';
var number = jQuery('title').text().match(/\[(.*)\]/)[1];
var title=jQuery('title').text().match('(])(.*)(-)')[2].trim().replace(/[ ~\^:]/g,'_').replace(/['"]/g,'\\$&');
copy('git checkout -b '+type+'/'+number+'--'+title);
Copy link

ghost commented Jun 18, 2020


javascript:function copy(text) {
    var input = document.createElement('input');
    input.setAttribute('value', text);
    document.body.appendChild(input);
    input.select();
    var result = document.execCommand('copy');
    document.body.removeChild(input);
    return result;
}
var type = $('#type-val').text().trim().toLowerCase();
var number = $('.issue-link').attr('data-issue-key').toLowerCase();
var title = jQuery('title').text().match('(])(.*)(-)')[2].trim().replace(/[ ~\^:]/g, '_').replace(/['"]/g, '\\$&');
var target = 'qa';
copy('git checkout ' + target + ' && git pull && git checkout -b "' + type + '/' + number + '-' + target + '_' + title + '"');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment