Skip to content

Instantly share code, notes, and snippets.

@Xayer
Last active March 8, 2019 11:44
Show Gist options
  • Save Xayer/938978544032f7c11ae0c7e45062c59c to your computer and use it in GitHub Desktop.
Save Xayer/938978544032f7c11ae0c7e45062c59c to your computer and use it in GitHub Desktop.
Finds Jira Ticket names in your commit messages, and adds them to a variable. copy to your javascript console, and watch magic happen.
var jiraDomain = 'https://jira.bonnier.dk/browse/';
var loadMore = document.querySelector('.ajax-pagination-btn');
var ticketNames = [];
var uniqueArray = function(arrArg) {
return arrArg.filter(function(elem, pos,arr) {
return arr.indexOf(elem) == pos;
});
};
if(loadMore !== null){
loadMore.click();
}
window.setTimeout(function(){ // Wait for render
const commits = document.querySelectorAll('.commit');
commits.forEach((commit) => {
const message = commit.querySelector('.commit-message code').textContent;
var regex = /\w+-\d+/g;
const match = message.match(regex);
if(match && match[0] !== 'null'){
ticketNames.push(match[0]);
}
});
ticketNames = uniqueArray(ticketNames);
ticketNames = ticketNames.map(function(ticketName) {
return jiraDomain + ticketName;
}).join('\n');
console.log(ticketNames)
}, 500);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment