Automate MSTR Server PR template

A script to help apply MSTR Server repo PR template automatically

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         Automate MSTR Server PR template
// @namespace    https://github.microstrategy.com/phuang/Tampermonkey
// @version      0.3
// @description  A script to help apply MSTR Server repo PR template automatically
// @author       Phuang
// @match        https://github.microstrategy.com/Tech/Server/compare/*
// @grant        none
// @require      https://code.jquery.com/jquery-3.4.1.min.js
// @run-at       document-end
// ==/UserScript==


function is_pr_hotfix() {
    var base_suggest = $('.commitish-suggester > summary')[0].innerHTML;
    return /compare\/m2020/i.test(window.location.href) || /base: m2020/i.test(base_suggest)
    || /compare\/2019_update/i.test(window.location.href) || /base: 2019_update/i.test(base_suggest)
    || /compare\/m2020_mci_dev/i.test(window.location.href) || /base: m2020_mci_dev/i.test(base_suggest)
    || /compare\/m2020_update/i.test(window.location.href) || /base: m2020_update/i.test(base_suggest);
}

function is_pr_defect() {
    return /DE\d{5}/i.test($('.discussion-topic-header > input')[0]['value']);
}

function is_pr_us() {
    return /US\d{5}/i.test($('.discussion-topic-header > input')[0]['value']);
}

function load_server_repo_pr_template() {
    var new_url = false;

    if (window.location.href.indexOf('template=') != -1) {
        return false;
    }else if (is_pr_hotfix()) {
        new_url = window.location.href+"&template=hotfix_release.md";
    }else if (is_pr_defect()) {
        new_url = window.location.href+"&template=sr_intelligence_defect.md";
    }else if (is_pr_us()) {
        new_url = window.location.href+"&template=sr_intelligence_us.md";
    }

    if (new_url) {
        window.location = new_url;
    }
}


(function() {
    'use strict';
    load_server_repo_pr_template();
})();