Last active
December 12, 2022 14:01
-
-
Save mehdichaouch/a0059044d24882a505022ae8fd417c30 to your computer and use it in GitHub Desktop.
๐ฟ Bookmarklet to generate a Git branch name from Jira issue
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
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta name="description" content="Bookmarklet - Generate a Git branch name from Jira issue by Mehdi Chaouch"> | |
<meta name="keywords" content="Bookmarklet,Git,Jira,issue"> | |
<meta name="author" content="Mehdi Chaouch"> | |
<!-- Author: https://gist.github.com/mehdichaouch --> | |
<!-- Required meta tags --> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<!-- Bootstrap CSS --> | |
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous"> | |
<!-- Custom styles for this template --> | |
<link rel="stylesheet" href="main.css"/> | |
<title>Bookmarklet - Generate a Git branch name from Jira issue by Mehdi Chaouch</title> | |
</head> | |
<body> | |
<!-- Fixed navbar --> | |
<header class="py-3 mb-4 border-bottom bg-light"> | |
<div class="container d-flex flex-wrap justify-content-center"> | |
<a href="https://github.com/mehdichaouch/bookmarklets" class="d-flex align-items-center mb-3 mb-lg-0 me-lg-auto text-dark text-decoration-none"> | |
<span class="fs-4">Bookmarklet</span> | |
</a> | |
</div> | |
</header> | |
<main role="main" class="container"> | |
<div class="container"> | |
<div class="row"> | |
<h1><a href="https://git.io/JnZbg">Generate a Git branch name from Jira issue</a></h1> | |
</div> | |
<div class="row"> | |
<p>This is a bookmarklet for Jira and Git user. It generate branch name from an issue.</p> | |
<p>To use it, just drag and drop link bellow in your bookmark, go to a Jira issue, click on bookmark.</p> | |
<p><a href="javascript:void%20function(){(function(e){var%20t=document.createElement(%22div%22),n=document.createElement(%22span%22),o=%22%22;t.style=%22cursor:pointer;position:fixed;top:0;left:0;width:100vw;height:100vh;display:flex;justify-content:center;align-items:center;background:%23FFF;z-index:999999;font-size:2em%22,sprintNode=null!==document.evaluate(%22//a[contains(%40href,%20'/secure/GHGoToBoard.jspa%3FsprintId=')]/text()%22,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue,(jQuery(%22title%22).text().includes(%22ECBOW%22)||jQuery(%22title%22).text().includes(%22ECPEA%22))%26%26sprintNode%26%26(o=%22sprint-%22+document.evaluate(%22//a[contains(%40href,%20'/secure/GHGoToBoard.jspa%3FsprintId=')]/text()%22,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue.textContent.split(%22-%22)[1]+%22/%22),n.textContent=%22Click%20to%20copy%20to%20clipboard:%20%22+o+e,t.append(n),t.onclick=function(n){n=document.createElement(%22textarea%22);var%20l=document.getSelection();n.textContent=o+e,document.body.appendChild(n),l.removeAllRanges(),n.select(),document.execCommand(%22copy%22),l.removeAllRanges(),document.body.removeChild(n),document.body.removeChild(t)},document.body.append(t)})(jQuery(%22title%22).text().replace(%22%20-%20Jira%22,%22%22).replace(/\[((RUN|ECBOW|ECPEA)-[\d]+)\]%20/g,%22$1/%22).replace(/[^a-zA-Z0-9-/%20]/g,%22%22).replace(/%20/g,%22-%22))}();">+Git branch name from Jira issue</a></p> | |
<details> | |
<summary>raw code</summary> | |
<pre> | |
<code class="language-js">(function(d) { | |
var a = document.createElement('div'), | |
b = document.createElement('span'), | |
sprint = ''; | |
a.style = 'cursor:pointer;position:fixed;top:0;left:0;width:100vw;height:100vh;display:flex;justify-content:center;align-items:center;background:#FFF;z-index:999999;font-size:2em'; | |
sprintNode = document.evaluate("//a[contains(@href, '/secure/GHGoToBoard.jspa?sprintId=')]/text()", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue !== null; | |
if ((jQuery('title').text().includes('ECBOW') || jQuery('title').text().includes('ECPEA')) && sprintNode) { | |
sprint = 'sprint-' + document.evaluate("//a[contains(@href, '/secure/GHGoToBoard.jspa?sprintId=')]/text()", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.textContent.split('-')[1] + '/' | |
} | |
b.textContent = 'Click to copy to clipboard: ' + sprint + d; | |
a.append(b); | |
a.onclick = function(c) { | |
c = document.createElement('textarea'); | |
var b = document.getSelection(); | |
c.textContent = sprint + d; | |
document.body.appendChild(c); | |
b.removeAllRanges(); | |
c.select(); | |
document.execCommand('copy'); | |
b.removeAllRanges(); | |
document.body.removeChild(c); | |
document.body.removeChild(a) | |
}; | |
document.body.append(a) | |
})(jQuery('title').text().replace(' - Jira', '').replace(/\[((RUN|ECBOW|ECPEA)-[\d]+)\] /g, '$1/').replace(/[^a-zA-Z0-9-/ ]/g, '').replace(/ /g, '-'));</code> | |
</pre> | |
<p>To generate bookmarklet: <a href="https://bookmarklets.org/maker/">Bookmarklet Maker with jQuery option</a></p> | |
</details> | |
</div> | |
</div> | |
</main> | |
<footer class="footer"> | |
<div class="container"> | |
<p>Made with <span class="love">โค</span> by <a href="https://github.com/mehdichaouch/">Mehdi Chaouch</a></p> | |
</div> | |
</footer> | |
<!-- Optional JavaScript; choose one of the two! --> | |
<!-- Option 1: Bootstrap Bundle with Popper --> | |
<!-- | |
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-gtEjrD/SeCtmISkJkNUaaKMoLD0//ElJ19smozuHV6z3Iehds+3Ulb9Bn9Plx0x4" crossorigin="anonymous"></script> | |
--> | |
<!-- Option 2: Separate Popper and Bootstrap JS --> | |
<!-- | |
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js" integrity="sha384-IQsoLXl5PILFhosVNubq5LC7Qb9DXgDA9i+tQ8Zj3iwWAwPtgFTxbJ8NT4GN1R8p" crossorigin="anonymous"></script> | |
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-Atwg2Pkwv9vp0ygtn1JAojH0nYbwNJLPhwyoVbhoPwBhjQPR5VtM2+xf0Uwh9KtT" crossorigin="anonymous"></script> | |
--> | |
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/styles/monokai-sublime.min.css" integrity="sha512-ade8vHOXH67Cm9z/U2vBpckPD1Enhdxl3N05ChXyFx5xikfqggrK4RrEele+VWY/iaZyfk7Bhk6CyZvlh7+5JQ==" crossorigin="anonymous" referrerpolicy="no-referrer" /> | |
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/highlight.min.js" integrity="sha512-bgHRAiTjGrzHzLyKOnpFvaEpGzJet3z4tZnXGjpsCcqOnAH6VGUx9frc5bcIhKTVLEiCO6vEhNAgx5jtLUYrfA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> | |
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/languages/javascript.min.js" integrity="sha512-/PyN7qb/AgAY5toh7Aq89f/DXt8AWSUxx++9ILRU/D4QwgjE3avvxL2Wi/Ft3aT22kzp29kgKc0o6GwTb+Jmnw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> | |
<script>hljs.highlightAll();</script> | |
</body> | |
</html> |
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
/* Sticky footer styles | |
-------------------------------------------------- */ | |
html { | |
position: relative; | |
min-height: 100%; | |
} | |
body { | |
margin-bottom: 60px; /* Margin bottom by footer height */ | |
} | |
.footer { | |
position: absolute; | |
bottom: 0; | |
width: 100%; | |
height: 60px; /* Set the fixed height of the footer here */ | |
line-height: 60px; /* Vertically center the text there */ | |
background-color: #f5f5f5; | |
} | |
/* Custom page CSS | |
-------------------------------------------------- */ | |
/* Not required for template or sticky footer method. */ | |
code { | |
font-size: 80%; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
๐ view last update of the page:
https://gist.githack.com/mehdichaouch/a0059044d24882a505022ae8fd417c30/raw/826fa6886c291037195b602577ebc42158e94e8e/generate-git-branch-name-from-jira-issue.html