Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save patrikvarga/01bd903b423f2f5a2b1b6e2aabac0d17 to your computer and use it in GitHub Desktop.
Save patrikvarga/01bd903b423f2f5a2b1b6e2aabac0d17 to your computer and use it in GitHub Desktop.
BitBucket PR merge message fix
// ==UserScript==
// @name BitBucket PR merge message fix
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Fix merge messages in BitBucket when merging pull requests to conform Git standard
// @author patrik
// @match https://bitbucket.org/*/*/pull-requests/*/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
console.log("BitBucket PR merge message fix loaded.");
$("body").on("DOMSubtreeModified", function() {
$("#id_commit_message:contains('Merged in ')").each(function() {
var targetBranchName = $("span.branch-name").eq(1).text();
var fixedCommitMessage = this.textContent
.replace("Merged in ", "Merge branch '")
.replace(" (pull request ", "' into " + targetBranchName + " (pull request ");
this.textContent = fixedCommitMessage;
console.log("Commit message replaced to: " + fixedCommitMessage);
});
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment