Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ merge_protections:

merge_protections_settings:
reporting_method: deployments
auto_merge: true
auto_merge_conditions: true
20 changes: 20 additions & 0 deletions src/__tests__/mergify.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2251,6 +2251,26 @@ describe("buildStackNav", () => {
el.querySelector('[data-mergify-stack-nav="next-empty"]'),
).not.toBeNull();
});

it("preserves the current subpath in prev/next links", () => {
const stack = stackOf(pull(1), pull(2, { is_current: true }), pull(3));
const el = buildStackNav(stack, {
org: "o",
repo: "r",
number: 2,
subpath: "changes",
});
expect(
el
.querySelector('[data-mergify-stack-nav="prev"]')
.getAttribute("href"),
).toBe("/o/r/pull/1/changes");
expect(
el
.querySelector('[data-mergify-stack-nav="next"]')
.getAttribute("href"),
).toBe("/o/r/pull/3/changes");
});
});

describe("injectStackNav", () => {
Expand Down
5 changes: 4 additions & 1 deletion src/mergify.js
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,7 @@ function getPullRequestData() {
org: parts[1],
repo: parts[2],
pull: parts[4],
subpath: parts[5] || "",
};
}

Expand Down Expand Up @@ -832,6 +833,7 @@ async function _tryInject() {
org: _data.org,
repo: _data.repo,
number: Number.parseInt(_data.pull, 10),
subpath: _data.subpath,
});

const existingRow = document.querySelector("#mergify");
Expand Down Expand Up @@ -1704,7 +1706,8 @@ function buildStackNav(stackData, currentPull) {
const a = document.createElement("a");
a.setAttribute("data-mergify-stack-nav", direction);
a.setAttribute("data-mergify-stack-nav-num", String(pull.number));
a.href = `/${currentPull.org}/${currentPull.repo}/pull/${pull.number}`;
const tail = currentPull.subpath ? `/${currentPull.subpath}` : "";
a.href = `/${currentPull.org}/${currentPull.repo}/pull/${pull.number}${tail}`;
a.title = `Open #${pull.number}: ${pull.title}`;
a.style.cssText =
"display:flex;align-items:center;gap:6px;" +
Expand Down