Last active
July 25, 2019 13:10
-
-
Save EmilienD/97342b6b352f08a6ac6e1d164ca329fc to your computer and use it in GitHub Desktop.
Unsophisticated user script to create branch name out of Jira ticket page (triggered by clicking on the tomato dot in the top right corner, or ctrl+shift+B)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name BRANCH_NAME_MAKER | |
| // @include https://qover001.atlassian.net/browse/* | |
| // @grant GM.setClipboard | |
| // ==/UserScript== | |
| const clickZone = document.createElement('div') | |
| clickZone.style = ` | |
| position: absolute; | |
| top: 15px; | |
| right: 15px; | |
| width: 30px; | |
| height: 30px; | |
| border-radius: 15px; | |
| background-color: tomato; | |
| z-index: 9001; | |
| transition: background-color 0.2s linear; | |
| ` | |
| clickZone.addEventListener('transitionend', () => { | |
| if(clickZone.style.backgroundColor !== 'tomato'){ clickZone.style.backgroundColor = 'tomato' } | |
| }) | |
| function branchNameToClipboard() { | |
| const branchPrefix = document.getElementById('type-val').innerText.match(/[Bb]ug/)? 'fix':'feature' | |
| const ticketId = location.pathname.split('/').pop() | |
| const ticketInfo = document.getElementById('summary-val').innerText.replace(/['\[\]-]/g, ' ').trim().replace(/ +/gi, '-') | |
| const branchName = `${branchPrefix}/${ticketId}-${ticketInfo}` | |
| const commandLine = 'git checkout -b ' | |
| GM.setClipboard(commandLine + branchName) | |
| clickZone.style.backgroundColor = '#FFF' | |
| } | |
| clickZone.addEventListener('click', branchNameToClipboard) | |
| document.querySelector('body').append(clickZone) | |
| document.addEventListener('keypress', e => { | |
| e.ctrlKey && e.shiftKey && e.key === 'B' && | |
| branchNameToClipboard() | |
| }) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Doesn't work with the new views ¯\_(ツ)_/¯