Last active
March 9, 2019 17:13
-
-
Save nonplus/39405f4e494b41c71212cf80bd5299fb to your computer and use it in GitHub Desktop.
This file contains 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 YouTrack - Git Branch | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Based on current YouTrack Ticket and logged in user, copy git branch command to the clipboard | |
// @author Stepan Riha | |
// @match https://*.myjetbrains.com/youtrack/issue/* | |
// @run-at context-menu | |
// @grant GM_setClipboard | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
var $name = document.querySelectorAll('[data-test="ring-dropdown ring-profile"]')[0]; | |
var issueid = location.pathname.split("/").pop() || ""; | |
var branch = ""; | |
var inls = ""; | |
if ($name && issueid.match(/-\d+$/)) { | |
inls = ($name.title || "").split(/\s+/).map(s => s[0] || "").join("").toLowerCase(); | |
branch = inls + "/" + issueid; | |
} else { | |
console.log("could not create branch name", { $name, issueid }); | |
} | |
if (branch) { | |
var cmd = "git checkout -b " + branch; | |
GM_setClipboard(cmd, 'text'); | |
alert(cmd); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment