Skip to content

Commit

Permalink
bitbucket-copy-commit-reference: fix Jira integration for Bitbucket S…
Browse files Browse the repository at this point in the history
…erver 8.9.*

As a follow-up to commit [1], fix Jira integration for Bitbucket Server
versions 8.9.*, where storage of Jira issue keys has changed, and now it
isn't available in a single dataset attribute.  In such cases, extract
the issue keys from links to Jira, automatically inserted into the
commit message.  Use dataset attribute with just the issue key from such
links to collect all keys into an array in method #getIssueKeys.

[1] 7f3790b (bitbucket-copy-commit-reference: support Bitbucket Server
    8.9.*, 2024-09-06)
  • Loading branch information
rybak committed Nov 7, 2024
1 parent 2a27ac6 commit 5ca43d7
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions bitbucket-copy-commit-reference.user.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ==UserScript==
// @name Bitbucket: copy commit reference
// @namespace https://github.com/rybak/atlassian-tweaks
// @version 12
// @version 13
// @description Adds a "Copy commit reference" link to every commit page on Bitbucket Cloud and Bitbucket Server.
// @license AGPL-3.0-only
// @author Andrei Rybak
Expand Down Expand Up @@ -401,7 +401,16 @@
#getIssueKeys() {
const issuesElem = document.querySelector('.plugin-section-primary .commit-issues-trigger');
if (!issuesElem) {
warn("Cannot find issues element");
if (!issuesElem) {
info("Newer version of Bitbucket Server with mangled CSS classes. Hold onto your butt.");
const keys = new Set();
document.querySelectorAll('[data-issuekey]').forEach(a => keys.add(a.dataset.issuekey));
const array = Array.from(keys);
if (array.length === 0) {
warn("Cannot find issues elements for Jira integration.");
}
return array;
}
return [];
}
const issueKeys = issuesElem.getAttribute('data-issue-keys').split(',');
Expand Down

0 comments on commit 5ca43d7

Please sign in to comment.