@veda-hq/niyam 0.7.8 → 0.7.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +54 -17
- package/dist/identity.js +46 -18
- package/package.json +3 -2
- package/scripts/merge-queue.mjs +91 -0
package/README.md
CHANGED
|
@@ -611,11 +611,22 @@ work pushed with the owner's login fails. Who pushed comes only from GitHub's
|
|
|
611
611
|
record of the pushes to the pull request's branch (the fork's, for a fork),
|
|
612
612
|
never from whoever started the run, so an edit, a reopen or a re-run by anyone
|
|
613
613
|
gives the result the push gave. A push GitHub has not recorded yet is waited
|
|
614
|
-
for about a minute, then fails until a re-run finds it. A
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
614
|
+
for about a minute, then fails until a re-run finds it. A `merge_group` run
|
|
615
|
+
passes with nothing to check, since each queued pull request was checked on its
|
|
616
|
+
own. So does Mergify's merge-queue draft, but only when it carries nothing else
|
|
617
|
+
(#524). That draft is a pull request `mergify[bot]`, a Bot, opened from a
|
|
618
|
+
`mergify/merge-queue/` branch of the repository itself, whose title names the
|
|
619
|
+
pull requests it tests (for a deep stack, the title counts those ahead and the
|
|
620
|
+
body's list names them), as Guard reads it (see Guard). Every commit on it must be
|
|
621
|
+
one of two kinds:
|
|
622
|
+
- one GitHub lists for a pull request it tests;
|
|
623
|
+
- Mergify's own merge of one: two parents, `Merge of PR N`, by `mergify[bot]`
|
|
624
|
+
and Verified as committed by `mergify-commit-signer`, which only Mergify can
|
|
625
|
+
sign as.
|
|
626
|
+
|
|
627
|
+
Anything else, including a draft a tested pull request's 250-commit limit hides
|
|
628
|
+
commits from, is checked as any pull request, saying why. So is anyone else's
|
|
629
|
+
pull request on such a branch. **Work rules** runs on the agent's
|
|
619
630
|
pull requests: each names exactly one slice, as a line `Slice: #N`, and that
|
|
620
631
|
slice may be built:
|
|
621
632
|
|
|
@@ -774,7 +785,9 @@ where the owner reacts, never the slice's top or the `needs-owner` list. A
|
|
|
774
785
|
waiting decision with no proposal yet gets the command that posts one,
|
|
775
786
|
`niyam propose <issue> --page <page url>` with its number. A
|
|
776
787
|
reaction does not re-run a pull request's checks: the agent proposes before
|
|
777
|
-
it starts, and pre-push or a re-run of Work rules sees the 👍.
|
|
788
|
+
it starts, and pre-push or a re-run of Work rules sees the 👍. The shared
|
|
789
|
+
Guard takes the same 👍 for a slice that changes a guard file (#515), so one
|
|
790
|
+
👍 settles both.
|
|
778
791
|
|
|
779
792
|
**Many at once.** `propose` takes several issues, `niyam propose 12
|
|
780
793
|
30 41 --page <url>`, and asks for each in turn, each comment linking that page. Where the settings name an Approvals issue
|
|
@@ -1728,7 +1741,7 @@ tag and the commit. Install the attached package on each machine with pnpm,
|
|
|
1728
1741
|
once; nothing is built on install:
|
|
1729
1742
|
|
|
1730
1743
|
```bash
|
|
1731
|
-
pnpm add -g https://github.com/veda-hq/niyam/releases/download/v0.7.
|
|
1744
|
+
pnpm add -g https://github.com/veda-hq/niyam/releases/download/v0.7.10/veda-hq-niyam-0.7.10.tgz
|
|
1732
1745
|
```
|
|
1733
1746
|
|
|
1734
1747
|
The package puts one command on `PATH`, `niyam`. Since P-57 a release
|
|
@@ -1836,14 +1849,23 @@ slice joined counts, wherever it is:
|
|
|
1836
1849
|
- a `Decision:` on its Work item naming it;
|
|
1837
1850
|
- a batch answer on the Approvals issue the default branch's settings name
|
|
1838
1851
|
(`"approvals": N`), whose first line opens `Decision: approve` and names the
|
|
1839
|
-
slice, as the work rules read it (#501)
|
|
1852
|
+
slice, as the work rules read it (#501);
|
|
1853
|
+
- a 👍 on a proposal for it by an agent the settings name (`"agent"`), whose
|
|
1854
|
+
first line opens `Proposal:` and names the slice as its first `#N`. The 👍
|
|
1855
|
+
must be made after the slice joined and after the proposal's last edit, as
|
|
1856
|
+
the work rules read it (#515). A proposal GitHub no longer has counts
|
|
1857
|
+
nothing.
|
|
1840
1858
|
|
|
1841
1859
|
If GitHub cannot find the Approvals issue, Guard counts nothing from it and
|
|
1842
1860
|
goes on. Any other failure to read it fails closed.
|
|
1843
1861
|
|
|
1844
1862
|
**Mergify's merge queue (#507).** Mergify tests a queued pull request in a draft of its own:
|
|
1845
1863
|
- opened as `mergify[bot]` on a `mergify/merge-queue/` branch of the repository;
|
|
1846
|
-
- titled `merge queue: checking #A on main (sha)`,
|
|
1864
|
+
- titled `merge queue: checking #A on main (sha)`, or `#A + #B together` for a batch (#524);
|
|
1865
|
+
- with `, stacked on #B` when it tests several;
|
|
1866
|
+
- or, from four ahead, `, stacked on N pull requests ahead`, whose numbers come from the body's `### Queued ahead of this batch` list, only when it names exactly N.
|
|
1867
|
+
|
|
1868
|
+
`scripts/merge-queue.mjs`, a guard file that imports nothing, reads this for Guard and for PR identity alike.
|
|
1847
1869
|
|
|
1848
1870
|
Guard judges that draft's own diff once with each tested pull request's title, author and body. It refuses a file only when every tested pull request leads to that refusal. So a guard file passes when one tested pull request's approved slice names it, or when its onboard or Dependabot exemption holds for the draft's diff. Guard never passes a draft solely because it is Mergify's: a file still needs a tested pull request's owner-approved slice, unless an existing onboard or Dependabot exemption applies.
|
|
1849
1871
|
|
|
@@ -1866,9 +1888,17 @@ items, so no slice to name a change: the shared Guard judges no slice there,
|
|
|
1866
1888
|
and its log lists each change it would have asked one to name. It still
|
|
1867
1889
|
refuses what no slice passes: a job added under the name of a check the
|
|
1868
1890
|
ruleset requires, a job that could report `niyam-guard / judge` but is not
|
|
1869
|
-
the caller `onboard` writes,
|
|
1870
|
-
lists. With `work-rules` on, or no
|
|
1871
|
-
a `features` it cannot read
|
|
1891
|
+
the caller `onboard` writes, a caller pinned off a niyam release, and a pull
|
|
1892
|
+
request with more files than GitHub lists. With `work-rules` on, or no
|
|
1893
|
+
`features` listed, it judges every change; a `features` it cannot read
|
|
1894
|
+
refuses.
|
|
1895
|
+
|
|
1896
|
+
**The caller's pin only moves forward (#512).** The caller's pin picks which Guard judges every pull request, so with work rules on or off, Guard refuses a changed workflow that calls `shared-guard.yml` at:
|
|
1897
|
+
- anything but a `vX.Y.Z` tag, such as a commit sha;
|
|
1898
|
+
- a tag not on niyam's `main`;
|
|
1899
|
+
- a release older than the one the default branch's copy of that file pins.
|
|
1900
|
+
|
|
1901
|
+
No `**Guards:**` line passes these. `onboard` writes only a forward move to a release, so its pull requests pass.
|
|
1872
1902
|
|
|
1873
1903
|
Two changes pass unnamed: an onboard pull request
|
|
1874
1904
|
(`chore(niyam): onboard at vX.Y.Z`) whose every changed line only moves the
|
|
@@ -1890,8 +1920,8 @@ gives none), never the calling repository or the pull request, and judges
|
|
|
1890
1920
|
the caller's pull request with the caller's token. A repository calls it
|
|
1891
1921
|
from a workflow run by `pull_request_target` alone, whose one job,
|
|
1892
1922
|
`niyam-guard` (id and name), only calls
|
|
1893
|
-
`veda-hq/niyam/.github/workflows/shared-guard.yml@vX.Y.Z` (a release tag
|
|
1894
|
-
|
|
1923
|
+
`veda-hq/niyam/.github/workflows/shared-guard.yml@vX.Y.Z` (a release tag on
|
|
1924
|
+
niyam's `main`, never a branch or a commit sha), read-only, with no inputs or secrets; its
|
|
1895
1925
|
check is `niyam-guard / judge`. The default branch is the repository's own,
|
|
1896
1926
|
whatever its name. `niyam onboard` writes that caller,
|
|
1897
1927
|
`.github/workflows/niyam-guard.yml`, in every repository it onboards,
|
|
@@ -1904,11 +1934,18 @@ Actions, Policies allows it for that workflow, so `onboard` names that step
|
|
|
1904
1934
|
there.
|
|
1905
1935
|
|
|
1906
1936
|
Guard cannot judge a change to its own rules, so `.github/CODEOWNERS` names
|
|
1907
|
-
`@AlokBansal8` for the guard's files alone:
|
|
1908
|
-
|
|
1909
|
-
|
|
1937
|
+
`@AlokBansal8` for the guard's files alone: `.github/workflows/shared-guard.yml`,
|
|
1938
|
+
`scripts/guard.mjs`, `scripts/guard.test.mjs`, the Mergify module it imports,
|
|
1939
|
+
`scripts/merge-queue.mjs` with its `scripts/merge-queue.test.mjs` (#524), and
|
|
1940
|
+
`.github/CODEOWNERS` itself. With "Require review from Code Owners" on in the `main` ruleset, a
|
|
1910
1941
|
pull request that changes one of them waits for his approval. Every other
|
|
1911
1942
|
pull request, including one under `.github/` that Guard passed, does not.
|
|
1943
|
+
The caller, `.github/workflows/niyam-guard.yml`, has no owner (#513), like
|
|
1944
|
+
every workflow but `shared-guard.yml`. Whatever the slice names, Guard holds the job that can
|
|
1945
|
+
report `niyam-guard / judge` to the caller's shape as `onboard` writes it, and
|
|
1946
|
+
its pin to forward moves to a niyam release (#512). Any other change to the
|
|
1947
|
+
file, another job included, passes only when an approved slice names it, as
|
|
1948
|
+
for any workflow. So niyam's own onboard merges on its checks.
|
|
1912
1949
|
|
|
1913
1950
|
## License
|
|
1914
1951
|
|
package/dist/identity.js
CHANGED
|
@@ -1,10 +1,38 @@
|
|
|
1
|
+
import { MERGE_QUEUE_BOT, mergifyTests, strayCommits } from '../scripts/merge-queue.mjs';
|
|
1
2
|
import { API, account, anyLogin, either, loadSettings, noreplyEmail, sameLogin } from './agent.js';
|
|
2
3
|
import { isOn, notAdoptedLine, offLine } from './features.js';
|
|
3
4
|
/** GitHub lists at most 250 commits for a pull request. */
|
|
4
5
|
const MOST_COMMITS = 250;
|
|
5
|
-
/**
|
|
6
|
-
|
|
7
|
-
const
|
|
6
|
+
/** Pull request `number`'s commits, as many as GitHub lists: MOST_COMMITS or more means some went unseen. */
|
|
7
|
+
async function commitsOf(sys, token, slug, number) {
|
|
8
|
+
const commits = [];
|
|
9
|
+
for (let page = 1;; page++) {
|
|
10
|
+
const { status, json } = await sys.http(`${API}/repos/${slug}/pulls/${number}/commits?per_page=100&page=${page}`, { token });
|
|
11
|
+
if (status !== 200 || !Array.isArray(json))
|
|
12
|
+
throw new Error(`cannot list the commits of #${number} (HTTP ${status})`);
|
|
13
|
+
commits.push(...json);
|
|
14
|
+
if (json.length < 100 || commits.length >= MOST_COMMITS)
|
|
15
|
+
return commits;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Why Mergify's draft, testing `tested`, does not carry only what they do, or
|
|
20
|
+
* undefined when every commit is a tested pull request's own or Mergify's
|
|
21
|
+
* signed merge of one (#524).
|
|
22
|
+
*/
|
|
23
|
+
async function strayFrom(sys, token, slug, commits, tested) {
|
|
24
|
+
const theirs = new Map();
|
|
25
|
+
for (const number of tested) {
|
|
26
|
+
const list = await commitsOf(sys, token, slug, number);
|
|
27
|
+
if (list.length >= MOST_COMMITS)
|
|
28
|
+
return `#${number} has ${MOST_COMMITS} or more commits, more than GitHub lists`;
|
|
29
|
+
theirs.set(number, list.map((commit) => commit.sha));
|
|
30
|
+
}
|
|
31
|
+
const stray = strayCommits(commits, theirs);
|
|
32
|
+
if (stray.length === 0)
|
|
33
|
+
return undefined;
|
|
34
|
+
return `${stray.map((sha) => sha.slice(0, 7)).join(', ')} ${stray.length === 1 ? 'is' : 'are'} in no pull request it tests and not ${MERGE_QUEUE_BOT}'s signed merge`;
|
|
35
|
+
}
|
|
8
36
|
/** GitHub may record a push a moment after the run starts: the record is read this many times, this far apart. */
|
|
9
37
|
const RECORD_READS = 6;
|
|
10
38
|
const RECORD_WAIT_MS = 10_000;
|
|
@@ -33,12 +61,6 @@ export async function prIdentity(sys, io) {
|
|
|
33
61
|
io.out('pr-identity: not a pull request; nothing to check');
|
|
34
62
|
return 0;
|
|
35
63
|
}
|
|
36
|
-
// Mergify's merge queue tests queued pull requests together on a branch of its own, which it opens and pushes.
|
|
37
|
-
// Each queued pull request passed this check on its own; anyone else's pull request on such a branch is checked.
|
|
38
|
-
if (pull.head.ref.startsWith(MERGE_QUEUE_BRANCH) && pull.user?.login === MERGE_QUEUE_BOT && pull.head.repo?.full_name === slug) {
|
|
39
|
-
io.out(`pr-identity: #${number} is ${MERGE_QUEUE_BOT}'s merge queue test of pull requests each checked on its own; nothing to check`);
|
|
40
|
-
return 0;
|
|
41
|
-
}
|
|
42
64
|
const notAdopted = notAdoptedLine(sys, sys.cwd, 'pr-identity');
|
|
43
65
|
if (notAdopted) {
|
|
44
66
|
io.out(notAdopted);
|
|
@@ -57,21 +79,27 @@ export async function prIdentity(sys, io) {
|
|
|
57
79
|
}));
|
|
58
80
|
const logins = accounts.map((one) => one.login);
|
|
59
81
|
const login = either(logins);
|
|
60
|
-
const commits =
|
|
61
|
-
for (let page = 1;; page++) {
|
|
62
|
-
const { status, json } = await sys.http(`${API}/repos/${slug}/pulls/${number}/commits?per_page=100&page=${page}`, { token });
|
|
63
|
-
if (status !== 200 || !Array.isArray(json))
|
|
64
|
-
throw new Error(`cannot list the commits of #${number} (HTTP ${status})`);
|
|
65
|
-
commits.push(...json);
|
|
66
|
-
if (json.length < 100 || commits.length >= MOST_COMMITS)
|
|
67
|
-
break;
|
|
68
|
-
}
|
|
82
|
+
const commits = await commitsOf(sys, token, slug, number);
|
|
69
83
|
if (commits.length >= MOST_COMMITS) {
|
|
70
84
|
// Commits past GitHub's limit cannot be seen, so they cannot pass.
|
|
71
85
|
io.err(`✗ #${number} has ${MOST_COMMITS} or more commits, more than GitHub lists; split it so every commit can be checked`);
|
|
72
86
|
io.err(`pr-identity: #${number} fails the identity check`);
|
|
73
87
|
return 1;
|
|
74
88
|
}
|
|
89
|
+
// Mergify's merge queue tests queued pull requests together in a draft of its own, which it opens and pushes,
|
|
90
|
+
// so their agent commits read as pushed by mergify[bot]. Each passed this check on its own, so the draft
|
|
91
|
+
// passes when it carries only their commits and Mergify's signed merges of them (#524). Any other draft,
|
|
92
|
+
// and a draft shaped as Mergify's that carries anything else, is checked as any pull request.
|
|
93
|
+
const tested = mergifyTests(pull, slug, number);
|
|
94
|
+
if (tested) {
|
|
95
|
+
const names = tested.map((one) => `#${one}`).join(', ');
|
|
96
|
+
const stray = await strayFrom(sys, token, slug, commits, tested);
|
|
97
|
+
if (stray === undefined) {
|
|
98
|
+
io.out(`pr-identity: #${number} is ${MERGE_QUEUE_BOT}'s merge queue draft testing ${names}, each checked on its own, and carries only their commits and ${MERGE_QUEUE_BOT}'s signed merges; nothing to check`);
|
|
99
|
+
return 0;
|
|
100
|
+
}
|
|
101
|
+
io.out(`pr-identity: #${number} is shaped as ${MERGE_QUEUE_BOT}'s merge queue draft testing ${names}, but ${stray}; checked as any pull request`);
|
|
102
|
+
}
|
|
75
103
|
/** The agent a commit claims, by its author's login or its no-reply address, or undefined. */
|
|
76
104
|
const claimed = (commit) => accounts.find((one) => sameLogin(commit.author?.login ?? undefined, one.login) || commit.commit?.author?.email?.toLowerCase() === one.email)?.login;
|
|
77
105
|
const claimsAgent = (commit) => claimed(commit) !== undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veda-hq/niyam",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.10",
|
|
4
4
|
"description": "Work rules for repos that track work in GitHub Issues: setup, agent identity, push and PR checks.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
"niyam": "dist/cli.js"
|
|
16
16
|
},
|
|
17
17
|
"files": [
|
|
18
|
-
"dist"
|
|
18
|
+
"dist",
|
|
19
|
+
"scripts/merge-queue.mjs"
|
|
19
20
|
],
|
|
20
21
|
"publishConfig": {
|
|
21
22
|
"access": "public",
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// Mergify's merge-queue draft, as the shared Guard (scripts/guard.mjs, #507)
|
|
2
|
+
// and PR identity (src/identity.ts, #524) both read it. A guard file
|
|
3
|
+
// (niyam's "guard": ["scripts/*.mjs"]), held for the owner in CODEOWNERS.
|
|
4
|
+
//
|
|
5
|
+
// Imports nothing on purpose: PR identity runs niyam's src/ with no install,
|
|
6
|
+
// so this cannot bring in a package, and Guard imports nothing from src/.
|
|
7
|
+
|
|
8
|
+
/** The account Mergify's merge queue opens its drafts as, and the branches it opens them on (`queue_branch_prefix`'s default). */
|
|
9
|
+
export const MERGE_QUEUE_BOT = 'mergify[bot]';
|
|
10
|
+
export const MERGE_QUEUE_BRANCH = 'mergify/merge-queue/';
|
|
11
|
+
/** The account GitHub verifies Mergify's own merge commits as (commit-signer@mergify.com), as on athya_mono#3822. */
|
|
12
|
+
export const MERGE_QUEUE_SIGNER = 'mergify-commit-signer';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* A merge-queue draft's title: `merge queue: checking #A on main (sha)`, a
|
|
16
|
+
* batch's `#A + #B together on main (sha)`, then `, stacked on #B, #C and #D`
|
|
17
|
+
* or, from four ahead, `, stacked on N pull requests ahead`. The groups are
|
|
18
|
+
* the tested pull requests, those the title names ahead, and the count ahead.
|
|
19
|
+
*/
|
|
20
|
+
const MERGE_QUEUE_TITLE =
|
|
21
|
+
/^merge queue: checking (#\d+(?: \+ #\d+)*)(?: together)? on \S+ \([0-9a-f]+\)(?:, stacked on (?:(#\d+(?:(?:,\s*|\s+and\s+)#\d+)*)|(\d+) pull requests ahead))?$/;
|
|
22
|
+
/** The body's list of the pull requests queued ahead, which a deep stack's title only counts. */
|
|
23
|
+
const QUEUED_AHEAD = /^### Queued ahead of this batch\n([\s\S]*?)(?=^#{1,3} |^<details>|(?![\s\S]))/m;
|
|
24
|
+
/** Mergify's merge of a tested pull request into its draft. */
|
|
25
|
+
const MERGE_OF = /^Merge of PR #?(\d+)$/;
|
|
26
|
+
|
|
27
|
+
const numbers = (text) => [...text.matchAll(/#(\d+)\b/g)].map((match) => Number(match[1]));
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Whether `pull` is shaped as Mergify's draft: GitHub names its author
|
|
31
|
+
* mergify[bot], a Bot, its head branch is on Mergify's queue prefix, and its
|
|
32
|
+
* head is the repository itself.
|
|
33
|
+
* @param {any} pull @param {string} repo @returns {boolean}
|
|
34
|
+
*/
|
|
35
|
+
export function isMergifyDraft(pull, repo) {
|
|
36
|
+
if (pull.user?.login !== MERGE_QUEUE_BOT || pull.user?.type !== 'Bot') return false;
|
|
37
|
+
return Boolean(pull.head?.ref?.startsWith(MERGE_QUEUE_BRANCH)) && pull.head?.repo?.full_name === repo;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The pull requests Mergify's merge-queue draft `pull` tests, from its title
|
|
42
|
+
* (and, for a deep stack, its body's list of those ahead, which must name as
|
|
43
|
+
* many as the title counts), or undefined when it is no such draft. A title
|
|
44
|
+
* that names none leaves it judged as itself.
|
|
45
|
+
* @param {any} pull @param {string} repo @param {number} pr @returns {number[] | undefined}
|
|
46
|
+
*/
|
|
47
|
+
export function mergifyTests(pull, repo, pr) {
|
|
48
|
+
if (!isMergifyDraft(pull, repo)) return undefined;
|
|
49
|
+
const title = MERGE_QUEUE_TITLE.exec(pull.title ?? '');
|
|
50
|
+
if (!title) return undefined;
|
|
51
|
+
const [, batch = '', stacked = '', ahead] = title;
|
|
52
|
+
const named = [...numbers(batch), ...numbers(stacked)];
|
|
53
|
+
if (ahead !== undefined) {
|
|
54
|
+
const queued = [...new Set(numbers(QUEUED_AHEAD.exec(pull.body ?? '')?.[1] ?? ''))];
|
|
55
|
+
if (queued.length !== Number(ahead)) return undefined;
|
|
56
|
+
named.push(...queued);
|
|
57
|
+
}
|
|
58
|
+
const tested = [...new Set(named)].filter((number) => number !== pr);
|
|
59
|
+
return tested.length > 0 ? tested : undefined;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Whether `commit` is Mergify's own merge of a pull request in `tested` into
|
|
64
|
+
* its draft: two parents, the message `Merge of PR N`, by mergify[bot], and
|
|
65
|
+
* Verified as committed by Mergify's signer, which only Mergify can sign as.
|
|
66
|
+
* @param {any} commit @param {number[]} tested @returns {boolean}
|
|
67
|
+
*/
|
|
68
|
+
export function isMergifyMerge(commit, tested) {
|
|
69
|
+
const number = MERGE_OF.exec(commit.commit?.message?.split('\n')[0] ?? '')?.[1];
|
|
70
|
+
return (
|
|
71
|
+
number !== undefined &&
|
|
72
|
+
tested.includes(Number(number)) &&
|
|
73
|
+
commit.parents?.length === 2 &&
|
|
74
|
+
commit.author?.login === MERGE_QUEUE_BOT &&
|
|
75
|
+
commit.committer?.login === MERGE_QUEUE_SIGNER &&
|
|
76
|
+
commit.commit?.verification?.verified === true
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* The commits of Mergify's draft that are neither a commit of a pull request
|
|
82
|
+
* it tests, as GitHub lists that pull request's commits (`theirs`, by
|
|
83
|
+
* number), nor Mergify's own merge of one. None means the draft carries only
|
|
84
|
+
* what the tested pull requests already do.
|
|
85
|
+
* @param {any[]} commits @param {Map<number, string[]>} theirs @returns {string[]}
|
|
86
|
+
*/
|
|
87
|
+
export function strayCommits(commits, theirs) {
|
|
88
|
+
const tested = [...theirs.keys()];
|
|
89
|
+
const known = new Set([...theirs.values()].flat());
|
|
90
|
+
return commits.filter((commit) => !known.has(commit.sha) && !isMergifyMerge(commit, tested)).map((commit) => commit.sha);
|
|
91
|
+
}
|