Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Add a git command to generate branch
// ==UserScript==
// @name StupidJira
// @namespace http://mikebell.io
// @version 0.1
// @description Add branch details
// @match https://jira.ctidigital.com/browse/*
// @grant none
//allow pasting
// ==/UserScript==
(function() {
var inputWrapper = document.createElement("form");
inputWrapper.className = 'aui';
inputWrapper.style.margin = '0 0 0 20px';
inputWrapper.style.left = '20px';
inputWrapper.style.width = '300px';
var input = document.createElement("input");
input.id = "stupidjira";
input.className = "text";
input.value = "git checkout -b ";
input.value += typereturn();
input.value += '/';
input.value += getTicketId();
input.onclick = function () {
this.select();
}
input.onmouseup = function () {
return false;
}
var container = document.getElementById("opsbar-opsbar-transitions");
inputWrapper.appendChild(input);
container.appendChild(inputWrapper);
function typereturn() {
var type = document.getElementById("type-val").textContent.trim();
if (type == 'Code Sub-task') {
return 'feature';
}
else if (type == 'Story') {
return 'feature';
}
else if (type == 'Task') {
return 'feature';
}
return 'bugfix';
}
function getTicketId() {
var metas = document.getElementsByTagName('meta');
for (i=0; i<metas.length; i++) {
if (metas[i].getAttribute("name") == "ajs-issue-key") {
return metas[i].getAttribute("content");
}
}
return "";
}
})();
@philwolstenholme

This comment has been minimized.

Copy link

@philwolstenholme philwolstenholme commented Oct 28, 2015

I forked this to add some formatting, default Jira form/input classes, and also an onfocus event that selects the git command for you:

https://gist.github.com/philwolstenholme/fe31065b932474cbbc2e

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