jira复制commit message

jira复制commit message,用于git等提交信息,可自由修改

目前為 2019-11-12 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         jira复制commit message
// @namespace    http://jira.netease.com/
// @version      0.1
// @description  jira复制commit message,用于git等提交信息,可自由修改
// @author       liuwenzhuang
// @match        *://jira.netease.com/*
// @require      https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js
// @grant        GM_setClipboard
// @grant        GM_notification
// @grant        window.close
// @run-at       document-end
// ==/UserScript==
(function(oldPushState) {
    'use strict';
    var $ = $ || window.$;
    var doc = document;
    window.history.pushState = function () {
        oldPushState.apply(window.history, arguments);
        setTimeout(insertCopyCommitMessage, 1000);
    }
    var insertCopyCommitMessage = function() {
        var copyLinkButton = $('#copyLinkButton');
        var copyCommitMessage = $('<a href="javascript: void(0);" style="margin-left:20px;cursor: pointer;" id="copyCommitMessageLinkButton">复制提交信息</a>');
        copyCommitMessage.appendTo(copyLinkButton.parent());
        copyCommitMessage.on('click', function(event){
            var jiraCode = $('#key-val').text();
            var jiraTitle = $('#summary-val').text();
            var jiraType = $('#type-val').text().trim();
            var commitType = 'feat';
            var tailMessage = '';
            switch(jiraType) {
                case '缺陷':
                    commitType = 'fix';
                    tailMessage = '\n\n' + '原因:' + '\n' + '方案:' + '\n' + '自测:'
                    break;
                case '子任务':
                case '故事':
                    commitType = 'feat';
                    break;
            }
            var result = '#' + jiraCode + ' ' + commitType + ':' + ' ' + jiraTitle + tailMessage;
            GM_setClipboard(result);
            GM_notification({
                text: '复制成功'
            });
        });
    }
    setTimeout(insertCopyCommitMessage, 1000);
})(window.history.pushState);