MCPcopy
hub / github.com/refined-github/refined-github / waitForPrMerge

Function waitForPrMerge

source/github-events/on-pr-merge.ts:7–23  ·  view source on GitHub ↗
(signal: AbortSignal)

Source from the content-addressed store, hash-verified

5
6// This event ensures that the feature appears exclusively to the person that merged the PR and not anyone who was on the page at the time of the merge
7export default async function waitForPrMerge(signal: AbortSignal): Promise<void> {
8 // It must start listening early or else the animation ID will be generated incorrectly (ancestor)
9 // WARNING: Be very careful about the value of ancestor if you refactor this code
10 const mergeEvent = new Promise(resolve => {
11 // `emphasis` excludes merge commit icons added by `mark-merge-commits-in-list`
12 observe('.TimelineItem-badge.color-fg-on-emphasis .octicon-git-merge', resolve, {ancestor: 4});
13 });
14
15 await oneEvent(confirmMergeButton, 'click', {signal});
16
17 // It won't resolve once the signal is aborted
18 await mergeEvent;
19
20 if (signal.aborted) {
21 throw new Error('The code shouldn’t have reached this point');
22 }
23}

Callers 3

initFunction · 0.85
initFunction · 0.85
initFunction · 0.85

Calls 1

observeFunction · 0.85

Tested by

no test coverage detected