Skip to content

Instantly share code, notes, and snippets.

@jacks0n
Last active June 15, 2017 17:20
Show Gist options
  • Save jacks0n/b51a2d6af8b76b4d6a27 to your computer and use it in GitHub Desktop.
Save jacks0n/b51a2d6af8b76b4d6a27 to your computer and use it in GitHub Desktop.
Generate a Git branch name from a JIRA ticket's project and title slug.
// Generated with http://chriszarate.github.io/bookmarkleter/
javascript:!function(){var%20e=document.getElementById(%22key-val%22).text,t=document.getElementById(%22summary-val%22).textContent,a=t.trim().replace(%22+%22,%22and%22).replace(/[^a-z0-9+]+/gi,%22_%22),n=%22feature/%22+e+%22_%22+a;window.prompt(%22Copy%20to%20clipboard%22,n)}();
var projectCode = document.getElementById('key-val').text,
ticketTitle = document.getElementById('summary-val').textContent;
var titleSlug = ticketTitle
.trim()
.replace('+', 'and')
.replace(/[^a-z0-9+]+/gi, '_')
var gitBranch = 'feature/' + projectCode + '_' + titleSlug;
window.prompt('Copy to clipboard', gitBranch);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment