Skip to content

Instantly share code, notes, and snippets.

@mikebell
Last active October 28, 2015 14:56
Show Gist options
  • Save mikebell/50b6b8408907c1e7441c to your computer and use it in GitHub Desktop.
Save mikebell/50b6b8408907c1e7441c to your computer and use it in GitHub Desktop.
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
Copy link

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