backport 11.0.2 → 12.0.0
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 +7 -8
- package/dist/src/entrypoint.api.d.ts +44 -21
- package/dist/src/entrypoint.api.js +9 -9
- package/dist/src/entrypoint.api.js.map +1 -1
- package/dist/src/graphql/generated/gql.d.ts +12 -12
- package/dist/src/graphql/generated/gql.js +6 -6
- package/dist/src/graphql/generated/gql.js.map +1 -1
- package/dist/src/graphql/generated/graphql.d.ts +274 -34600
- package/dist/src/graphql/generated/graphql.js +6 -3512
- package/dist/src/graphql/generated/graphql.js.map +1 -1
- package/dist/src/lib/backport-error.js +1 -1
- package/dist/src/lib/backport-error.js.map +1 -1
- package/dist/src/lib/cherrypickAndCreateTargetPullRequest/auto-merge-now-or-later.d.ts +1 -1
- package/dist/src/lib/cherrypickAndCreateTargetPullRequest/auto-merge-now-or-later.js +4 -4
- package/dist/src/lib/cherrypickAndCreateTargetPullRequest/auto-merge-now-or-later.js.map +1 -1
- package/dist/src/lib/cherrypickAndCreateTargetPullRequest/copy-source-pull-request-reviewers-to-target-pull-request.d.ts +1 -1
- package/dist/src/lib/cherrypickAndCreateTargetPullRequest/copy-source-pull-request-reviewers-to-target-pull-request.js +2 -2
- package/dist/src/lib/cherrypickAndCreateTargetPullRequest/copy-source-pull-request-reviewers-to-target-pull-request.js.map +1 -1
- package/dist/src/lib/cherrypickAndCreateTargetPullRequest/get-commits-without-backports.js +3 -3
- package/dist/src/lib/cherrypickAndCreateTargetPullRequest/get-commits-without-backports.js.map +1 -1
- package/dist/src/lib/cherrypickAndCreateTargetPullRequest/wait-for-cherrypick.js +3 -6
- package/dist/src/lib/cherrypickAndCreateTargetPullRequest/wait-for-cherrypick.js.map +1 -1
- package/dist/src/lib/child-process-promisified.js +2 -0
- package/dist/src/lib/child-process-promisified.js.map +1 -1
- package/dist/src/lib/env.d.ts +1 -1
- package/dist/src/lib/env.js +3 -3
- package/dist/src/lib/env.js.map +1 -1
- package/dist/src/lib/get-commits.js +5 -5
- package/dist/src/lib/get-commits.js.map +1 -1
- package/dist/src/lib/git/cherrypick.js +1 -1
- package/dist/src/lib/git/remote.d.ts +2 -2
- package/dist/src/lib/git/remote.js +4 -4
- package/dist/src/lib/git/remote.js.map +1 -1
- package/dist/src/lib/github/v3/add-assignees-to-pull-request.d.ts +2 -2
- package/dist/src/lib/github/v3/add-assignees-to-pull-request.js +2 -2
- package/dist/src/lib/github/v3/add-labels-to-pull-request.d.ts +2 -2
- package/dist/src/lib/github/v3/add-labels-to-pull-request.js +2 -2
- package/dist/src/lib/github/v3/add-reviewers-to-pull-request.d.ts +2 -2
- package/dist/src/lib/github/v3/add-reviewers-to-pull-request.js +2 -2
- package/dist/src/lib/github/v3/create-pull-request/create-pull-request.js +3 -3
- package/dist/src/lib/github/v3/create-pull-request/create-pull-request.js.map +1 -1
- package/dist/src/lib/github/v3/create-status-comment.js +4 -4
- package/dist/src/lib/github/v3/get-reviewers-from-pull-requests.d.ts +1 -1
- package/dist/src/lib/github/v3/get-reviewers-from-pull-requests.js +4 -4
- package/dist/src/lib/github/v3/get-reviewers-from-pull-requests.js.map +1 -1
- package/dist/src/lib/github/v3/merge-pull-request.js +2 -2
- package/dist/src/lib/github/v3/octokit-client.d.ts +2 -2
- package/dist/src/lib/github/v3/octokit-client.js +2 -2
- package/dist/src/lib/github/v4/client/graphql-client.d.ts +2 -2
- package/dist/src/lib/github/v4/client/graphql-client.js +2 -2
- package/dist/src/lib/github/v4/disable-pull-request-auto-merge.js +2 -2
- package/dist/src/lib/github/v4/enable-pull-request-auto-merge.js +6 -7
- package/dist/src/lib/github/v4/enable-pull-request-auto-merge.js.map +1 -1
- package/dist/src/lib/github/v4/fetch-author-id.d.ts +2 -2
- package/dist/src/lib/github/v4/fetch-author-id.js +2 -2
- package/dist/src/lib/github/v4/fetch-existing-pull-request.d.ts +1 -1
- package/dist/src/lib/github/v4/fetch-existing-pull-request.js +2 -2
- package/dist/src/lib/github/v4/fetch-pull-request-auto-merge-method.js +5 -5
- package/dist/src/lib/github/v4/fetch-pull-request-auto-merge-method.js.map +1 -1
- package/dist/src/lib/github/v4/fetch-pull-request-id.js +5 -9
- package/dist/src/lib/github/v4/fetch-pull-request-id.js.map +1 -1
- package/dist/src/lib/github/v4/fetchCommits/fetch-commit-by-pull-number.d.ts +1 -1
- package/dist/src/lib/github/v4/fetchCommits/fetch-commit-by-pull-number.js +9 -6
- package/dist/src/lib/github/v4/fetchCommits/fetch-commit-by-pull-number.js.map +1 -1
- package/dist/src/lib/github/v4/fetchCommits/fetch-commit-by-sha.d.ts +1 -1
- package/dist/src/lib/github/v4/fetchCommits/fetch-commit-by-sha.js +2 -2
- package/dist/src/lib/github/v4/fetchCommits/fetch-commits-by-author.d.ts +4 -4
- package/dist/src/lib/github/v4/fetchCommits/fetch-commits-by-author.js +13 -13
- package/dist/src/lib/github/v4/fetchCommits/fetch-commits-by-author.js.map +1 -1
- package/dist/src/lib/github/v4/fetchCommits/fetch-commits-for-rebase-and-merge-strategy.d.ts +1 -1
- package/dist/src/lib/github/v4/fetchCommits/fetch-commits-for-rebase-and-merge-strategy.js +8 -6
- package/dist/src/lib/github/v4/fetchCommits/fetch-commits-for-rebase-and-merge-strategy.js.map +1 -1
- package/dist/src/lib/github/v4/fetchCommits/fetch-pull-requests-by-search-query.d.ts +5 -5
- package/dist/src/lib/github/v4/fetchCommits/fetch-pull-requests-by-search-query.js +13 -13
- package/dist/src/lib/github/v4/fetchCommits/fetch-pull-requests-by-search-query.js.map +1 -1
- package/dist/src/lib/github/v4/{get-invalid-access-token-message.d.ts → get-invalid-github-token-message.d.ts} +2 -1
- package/dist/src/lib/github/v4/{get-invalid-access-token-message.js → get-invalid-github-token-message.js} +9 -5
- package/dist/src/lib/github/v4/get-invalid-github-token-message.js.map +1 -0
- package/dist/src/lib/github/v4/get-repo-owner-and-name-from-git-remotes.d.ts +2 -2
- package/dist/src/lib/github/v4/get-repo-owner-and-name-from-git-remotes.js +2 -2
- package/dist/src/lib/github/v4/getOptionsFromGithub/get-options-from-github.d.ts +40 -17
- package/dist/src/lib/github/v4/getOptionsFromGithub/get-options-from-github.js +15 -14
- package/dist/src/lib/github/v4/getOptionsFromGithub/get-options-from-github.js.map +1 -1
- package/dist/src/lib/github/v4/index.d.ts +1 -1
- package/dist/src/lib/github/v4/index.js +1 -1
- package/dist/src/lib/github/v4/mocks/commits-by-author-mock.js +1 -2
- package/dist/src/lib/github/v4/mocks/commits-by-author-mock.js.map +1 -1
- package/dist/src/lib/github/v4/validate-target-branch.d.ts +2 -2
- package/dist/src/lib/github/v4/validate-target-branch.js +2 -2
- package/dist/src/lib/logger.d.ts +5 -5
- package/dist/src/lib/logger.js +13 -13
- package/dist/src/lib/remote-config.d.ts +90 -1
- package/dist/src/lib/run-sequentially.js +1 -1
- package/dist/src/lib/run-sequentially.js.map +1 -1
- package/dist/src/lib/setup-repo.js +2 -2
- package/dist/src/lib/sourceCommit/get-pull-request-states.js +4 -4
- package/dist/src/lib/sourceCommit/get-pull-request-states.js.map +1 -1
- package/dist/src/lib/sourceCommit/get-source-pull-request.d.ts +21 -191
- package/dist/src/lib/sourceCommit/parse-source-commit.js +4 -4
- package/dist/src/lib/sourceCommit/parse-source-commit.js.map +1 -1
- package/dist/src/options/cli-args.d.ts +10 -11
- package/dist/src/options/cli-args.js +85 -53
- package/dist/src/options/cli-args.js.map +1 -1
- package/dist/src/options/config/config.d.ts +184 -66
- package/dist/src/options/config/config.js +6 -3
- package/dist/src/options/config/config.js.map +1 -1
- package/dist/src/options/config/global-config.js +2 -2
- package/dist/src/options/config/read-config-file.d.ts +1 -0
- package/dist/src/options/config/read-config-file.js +60 -4
- package/dist/src/options/config/read-config-file.js.map +1 -1
- package/dist/src/options/config-options.d.ts +8 -95
- package/dist/src/options/option-schema.d.ts +169 -24
- package/dist/src/options/option-schema.js +65 -18
- package/dist/src/options/option-schema.js.map +1 -1
- package/dist/src/options/options.d.ts +1 -2
- package/dist/src/options/options.js +106 -50
- package/dist/src/options/options.js.map +1 -1
- package/package.json +24 -24
- package/dist/src/lib/github/v4/get-invalid-access-token-message.js.map +0 -1
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { PullRequestMergeMethod } from '../../../graphql/generated/graphql.js';
|
|
2
1
|
import { graphql } from '../../../graphql/generated/index.js';
|
|
3
2
|
import { BackportError } from '../../backport-error.js';
|
|
4
3
|
import { graphqlRequest } from './client/graphql-client.js';
|
|
5
4
|
import { fetchPullRequestId } from './fetch-pull-request-id.js';
|
|
6
5
|
export async function enablePullRequestAutoMerge(options, targetPullRequestNumber) {
|
|
7
|
-
const {
|
|
6
|
+
const { githubToken, githubApiBaseUrlV4, autoMergeMethod = 'merge', } = options;
|
|
8
7
|
const pullRequestId = await fetchPullRequestId(options, targetPullRequestNumber);
|
|
9
8
|
const query = graphql(`
|
|
10
9
|
mutation EnablePullRequestAutoMerge(
|
|
@@ -21,15 +20,15 @@ export async function enablePullRequestAutoMerge(options, targetPullRequestNumbe
|
|
|
21
20
|
}
|
|
22
21
|
`);
|
|
23
22
|
const mergeMethodMap = {
|
|
24
|
-
merge:
|
|
25
|
-
squash:
|
|
26
|
-
rebase:
|
|
23
|
+
merge: 'MERGE',
|
|
24
|
+
squash: 'SQUASH',
|
|
25
|
+
rebase: 'REBASE',
|
|
27
26
|
};
|
|
28
27
|
const variables = {
|
|
29
28
|
pullRequestId,
|
|
30
|
-
mergeMethod: mergeMethodMap[autoMergeMethod] ??
|
|
29
|
+
mergeMethod: mergeMethodMap[autoMergeMethod] ?? 'MERGE',
|
|
31
30
|
};
|
|
32
|
-
const result = await graphqlRequest({
|
|
31
|
+
const result = await graphqlRequest({ githubToken, githubApiBaseUrlV4 }, query, variables);
|
|
33
32
|
if (result.error) {
|
|
34
33
|
if (isMissingStatusChecksError(result)) {
|
|
35
34
|
throw new BackportError({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enable-pull-request-auto-merge.js","sourceRoot":"","sources":["../../../../../src/lib/github/v4/enable-pull-request-auto-merge.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"enable-pull-request-auto-merge.js","sourceRoot":"","sources":["../../../../../src/lib/github/v4/enable-pull-request-auto-merge.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,qCAAqC,CAAC;AAE9D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,OAA2B,EAC3B,uBAA+B;IAE/B,MAAM,EACJ,WAAW,EACX,kBAAkB,EAClB,eAAe,GAAG,OAAO,GAC1B,GAAG,OAAO,CAAC;IAEZ,MAAM,aAAa,GAAG,MAAM,kBAAkB,CAC5C,OAAO,EACP,uBAAuB,CACxB,CAAC;IAEF,MAAM,KAAK,GAAG,OAAO,CAAC;;;;;;;;;;;;;GAarB,CAAC,CAAC;IAEH,MAAM,cAAc,GAA2C;QAC7D,KAAK,EAAE,OAAO;QACd,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE,QAAQ;KACjB,CAAC;IAEF,MAAM,SAAS,GAAG;QAChB,aAAa;QACb,WAAW,EAAE,cAAc,CAAC,eAAe,CAAC,IAAI,OAAO;KACxD,CAAC;IAEF,MAAM,MAAM,GAAG,MAAM,cAAc,CACjC,EAAE,WAAW,EAAE,kBAAkB,EAAE,EACnC,KAAK,EACL,SAAS,CACV,CAAC;IAEF,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;QACjB,IAAI,0BAA0B,CAAC,MAAM,CAAC,EAAE,CAAC;YACvC,MAAM,IAAI,aAAa,CAAC;gBACtB,IAAI,EAAE,oCAAoC;gBAC1C,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,OAAO;aAC9B,CAAC,CAAC;QACL,CAAC;QACD,MAAM,IAAI,aAAa,CAAC;YACtB,IAAI,EAAE,sBAAsB;YAC5B,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,OAAO;SAC9B,CAAC,CAAC;IACL,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,EAAE,0BAA0B,EAAE,WAAW,EAAE,MAAM,CAAC;AACtE,CAAC;AAED,SAAS,0BAA0B,CAAC,MAAwC;IAC1E,OAAO,MAAM,CAAC,KAAK,EAAE,aAAa,CAAC,IAAI,CACrC,CAAC,CAAC,EAAE,EAAE,CACJ,CAAC,CAAC,UAAU,CAAC,IAAI,KAAK,eAAe;QACrC,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CACjB,sDAAsD,CACvD;YACC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,iCAAiC,CAAC,CAAC,CAC3D,CAAC;AACJ,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export declare function fetchAuthorId({
|
|
2
|
-
|
|
1
|
+
export declare function fetchAuthorId({ githubToken, author, githubApiBaseUrlV4, }: {
|
|
2
|
+
githubToken: string;
|
|
3
3
|
author: string | null;
|
|
4
4
|
githubApiBaseUrlV4?: string;
|
|
5
5
|
}): Promise<string | null | undefined>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { graphql } from '../../../graphql/generated/index.js';
|
|
2
2
|
import { BackportError } from '../../backport-error.js';
|
|
3
3
|
import { graphqlRequest } from './client/graphql-client.js';
|
|
4
|
-
export async function fetchAuthorId({
|
|
4
|
+
export async function fetchAuthorId({ githubToken, author, githubApiBaseUrlV4 = 'https://api.github.com/graphql', }) {
|
|
5
5
|
if (author === null) {
|
|
6
6
|
return null;
|
|
7
7
|
}
|
|
@@ -13,7 +13,7 @@ export async function fetchAuthorId({ accessToken, author, githubApiBaseUrlV4 =
|
|
|
13
13
|
}
|
|
14
14
|
`);
|
|
15
15
|
const variables = { author };
|
|
16
|
-
const result = await graphqlRequest({
|
|
16
|
+
const result = await graphqlRequest({ githubToken, githubApiBaseUrlV4 }, query, variables);
|
|
17
17
|
if (result.error) {
|
|
18
18
|
throw new BackportError({
|
|
19
19
|
code: 'github-api-exception',
|
|
@@ -3,7 +3,7 @@ import { graphql } from '../../../graphql/generated/index.js';
|
|
|
3
3
|
import { BackportError } from '../../backport-error.js';
|
|
4
4
|
import { graphqlRequest } from './client/graphql-client.js';
|
|
5
5
|
export async function fetchExistingPullRequest({ options, prPayload, }) {
|
|
6
|
-
const { githubApiBaseUrlV4,
|
|
6
|
+
const { githubApiBaseUrlV4, githubToken } = options;
|
|
7
7
|
const query = graphql(`
|
|
8
8
|
query ExistingPullRequest(
|
|
9
9
|
$repoOwner: String!
|
|
@@ -39,7 +39,7 @@ export async function fetchExistingPullRequest({ options, prPayload, }) {
|
|
|
39
39
|
base: prPayload.base,
|
|
40
40
|
head: head,
|
|
41
41
|
};
|
|
42
|
-
const result = await graphqlRequest({
|
|
42
|
+
const result = await graphqlRequest({ githubToken, githubApiBaseUrlV4 }, query, variables);
|
|
43
43
|
if (result.error) {
|
|
44
44
|
throw new BackportError({
|
|
45
45
|
code: 'github-api-exception',
|
|
@@ -2,15 +2,15 @@ import { graphql } from '../../../graphql/generated/index.js';
|
|
|
2
2
|
import { BackportError } from '../../backport-error.js';
|
|
3
3
|
import { graphqlRequest } from './client/graphql-client.js';
|
|
4
4
|
export async function fetchPullRequestAutoMergeMethod(options, pullNumber) {
|
|
5
|
-
const {
|
|
5
|
+
const { githubToken, githubApiBaseUrlV4, repoName, repoOwner } = options;
|
|
6
6
|
const query = graphql(`
|
|
7
7
|
query PullRequestAutoMergeMethod(
|
|
8
8
|
$repoOwner: String!
|
|
9
9
|
$repoName: String!
|
|
10
|
-
$
|
|
10
|
+
$pr: Int!
|
|
11
11
|
) {
|
|
12
12
|
repository(owner: $repoOwner, name: $repoName) {
|
|
13
|
-
pullRequest(number: $
|
|
13
|
+
pullRequest(number: $pr) {
|
|
14
14
|
autoMergeRequest {
|
|
15
15
|
enabledAt
|
|
16
16
|
mergeMethod
|
|
@@ -22,9 +22,9 @@ export async function fetchPullRequestAutoMergeMethod(options, pullNumber) {
|
|
|
22
22
|
const variables = {
|
|
23
23
|
repoOwner,
|
|
24
24
|
repoName,
|
|
25
|
-
pullNumber,
|
|
25
|
+
pr: pullNumber,
|
|
26
26
|
};
|
|
27
|
-
const result = await graphqlRequest({
|
|
27
|
+
const result = await graphqlRequest({ githubToken, githubApiBaseUrlV4 }, query, variables);
|
|
28
28
|
if (result.error) {
|
|
29
29
|
throw new BackportError({
|
|
30
30
|
code: 'github-api-exception',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-pull-request-auto-merge-method.js","sourceRoot":"","sources":["../../../../../src/lib/github/v4/fetch-pull-request-auto-merge-method.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qCAAqC,CAAC;AAE9D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D,MAAM,CAAC,KAAK,UAAU,+BAA+B,CACnD,OAA2B,EAC3B,UAAkB;IAElB,MAAM,EAAE,WAAW,EAAE,kBAAkB,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAEzE,MAAM,KAAK,GAAG,OAAO,CAAC;;;;;;;;;;;;;;;GAerB,CAAC,CAAC;IACH,MAAM,SAAS,GAAG;QAChB,SAAS;QACT,QAAQ;QACR,UAAU;
|
|
1
|
+
{"version":3,"file":"fetch-pull-request-auto-merge-method.js","sourceRoot":"","sources":["../../../../../src/lib/github/v4/fetch-pull-request-auto-merge-method.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qCAAqC,CAAC;AAE9D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D,MAAM,CAAC,KAAK,UAAU,+BAA+B,CACnD,OAA2B,EAC3B,UAAkB;IAElB,MAAM,EAAE,WAAW,EAAE,kBAAkB,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAEzE,MAAM,KAAK,GAAG,OAAO,CAAC;;;;;;;;;;;;;;;GAerB,CAAC,CAAC;IACH,MAAM,SAAS,GAAG;QAChB,SAAS;QACT,QAAQ;QACR,EAAE,EAAE,UAAU;KACf,CAAC;IACF,MAAM,MAAM,GAAG,MAAM,cAAc,CACjC,EAAE,WAAW,EAAE,kBAAkB,EAAE,EACnC,KAAK,EACL,SAAS,CACV,CAAC;IAEF,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;QACjB,MAAM,IAAI,aAAa,CAAC;YACtB,IAAI,EAAE,sBAAsB;YAC5B,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,OAAO;SAC9B,CAAC,CAAC;IACL,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,gBAAgB,EAAE,WAAW,CAAC;AAC7E,CAAC"}
|
|
@@ -2,22 +2,18 @@ import { graphql } from '../../../graphql/generated/index.js';
|
|
|
2
2
|
import { BackportError } from '../../backport-error.js';
|
|
3
3
|
import { graphqlRequest } from './client/graphql-client.js';
|
|
4
4
|
export async function fetchPullRequestId(options, pullNumber) {
|
|
5
|
-
const {
|
|
5
|
+
const { githubToken, githubApiBaseUrlV4, repoName, repoOwner } = options;
|
|
6
6
|
const query = graphql(`
|
|
7
|
-
query PullRequestId(
|
|
8
|
-
$repoOwner: String!
|
|
9
|
-
$repoName: String!
|
|
10
|
-
$pullNumber: Int!
|
|
11
|
-
) {
|
|
7
|
+
query PullRequestId($repoOwner: String!, $repoName: String!, $pr: Int!) {
|
|
12
8
|
repository(owner: $repoOwner, name: $repoName) {
|
|
13
|
-
pullRequest(number: $
|
|
9
|
+
pullRequest(number: $pr) {
|
|
14
10
|
id
|
|
15
11
|
}
|
|
16
12
|
}
|
|
17
13
|
}
|
|
18
14
|
`);
|
|
19
|
-
const variables = { repoOwner, repoName, pullNumber };
|
|
20
|
-
const result = await graphqlRequest({
|
|
15
|
+
const variables = { repoOwner, repoName, pr: pullNumber };
|
|
16
|
+
const result = await graphqlRequest({ githubToken, githubApiBaseUrlV4 }, query, variables);
|
|
21
17
|
if (result.error) {
|
|
22
18
|
throw new BackportError({
|
|
23
19
|
code: 'github-api-exception',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-pull-request-id.js","sourceRoot":"","sources":["../../../../../src/lib/github/v4/fetch-pull-request-id.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qCAAqC,CAAC;AAE9D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,OAA2B,EAC3B,UAAkB;IAElB,MAAM,EAAE,WAAW,EAAE,kBAAkB,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAEzE,MAAM,KAAK,GAAG,OAAO,CAAC
|
|
1
|
+
{"version":3,"file":"fetch-pull-request-id.js","sourceRoot":"","sources":["../../../../../src/lib/github/v4/fetch-pull-request-id.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qCAAqC,CAAC;AAE9D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,OAA2B,EAC3B,UAAkB;IAElB,MAAM,EAAE,WAAW,EAAE,kBAAkB,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAEzE,MAAM,KAAK,GAAG,OAAO,CAAC;;;;;;;;GAQrB,CAAC,CAAC;IAEH,MAAM,SAAS,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC;IAC1D,MAAM,MAAM,GAAG,MAAM,cAAc,CACjC,EAAE,WAAW,EAAE,kBAAkB,EAAE,EACnC,KAAK,EACL,SAAS,CACV,CAAC;IAEF,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;QACjB,MAAM,IAAI,aAAa,CAAC;YACtB,IAAI,EAAE,sBAAsB;YAC5B,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,OAAO;SAC9B,CAAC,CAAC;IACL,CAAC;IAED,MAAM,aAAa,GAAG,MAAM,CAAC,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,EAAE,CAAC;IAC/D,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,MAAM,IAAI,aAAa,CAAC;YACtB,IAAI,EAAE,wBAAwB;YAC9B,UAAU;SACX,CAAC,CAAC;IACL,CAAC;IAED,OAAO,aAAa,CAAC;AACvB,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ValidConfigOptions } from '../../../../options/options.js';
|
|
2
2
|
import type { Commit } from '../../../sourceCommit/parse-source-commit.js';
|
|
3
3
|
export declare function fetchCommitsByPullNumber(options: {
|
|
4
|
-
|
|
4
|
+
githubToken: string;
|
|
5
5
|
branchLabelMapping?: ValidConfigOptions['branchLabelMapping'];
|
|
6
6
|
githubApiBaseUrlV4?: string;
|
|
7
7
|
pullNumber: number;
|
|
@@ -5,15 +5,15 @@ import { graphqlRequest } from '../client/graphql-client.js';
|
|
|
5
5
|
import { fetchCommitBySha } from './fetch-commit-by-sha.js';
|
|
6
6
|
import { fetchCommitsForRebaseAndMergeStrategy } from './fetch-commits-for-rebase-and-merge-strategy.js';
|
|
7
7
|
export async function fetchCommitsByPullNumber(options) {
|
|
8
|
-
const {
|
|
8
|
+
const { githubToken, githubApiBaseUrlV4 = 'https://api.github.com/graphql', pullNumber, repoName, repoOwner, } = options;
|
|
9
9
|
const query = graphql(`
|
|
10
10
|
query CommitByPullNumber(
|
|
11
11
|
$repoOwner: String!
|
|
12
12
|
$repoName: String!
|
|
13
|
-
$
|
|
13
|
+
$pr: Int!
|
|
14
14
|
) {
|
|
15
15
|
repository(owner: $repoOwner, name: $repoName) {
|
|
16
|
-
pullRequest(number: $
|
|
16
|
+
pullRequest(number: $pr) {
|
|
17
17
|
# used to determine if "Rebase and Merge" strategy was used
|
|
18
18
|
commits(last: 1) {
|
|
19
19
|
totalCount
|
|
@@ -44,8 +44,8 @@ export async function fetchCommitsByPullNumber(options) {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
`);
|
|
47
|
-
const variables = { repoOwner, repoName, pullNumber };
|
|
48
|
-
const result = await graphqlRequest({
|
|
47
|
+
const variables = { repoOwner, repoName, pr: pullNumber };
|
|
48
|
+
const result = await graphqlRequest({ githubToken, githubApiBaseUrlV4 }, query, variables);
|
|
49
49
|
if (result.error && !isMissingConfigFileException(result)) {
|
|
50
50
|
throw new BackportError({
|
|
51
51
|
code: 'github-api-exception',
|
|
@@ -78,7 +78,10 @@ export async function fetchCommitsByPullNumber(options) {
|
|
|
78
78
|
return commits;
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
|
-
const commit = await fetchCommitBySha({
|
|
81
|
+
const commit = await fetchCommitBySha({
|
|
82
|
+
...options,
|
|
83
|
+
sha: String(mergeCommit.oid),
|
|
84
|
+
});
|
|
82
85
|
return [commit];
|
|
83
86
|
}
|
|
84
87
|
//# sourceMappingURL=fetch-commit-by-pull-number.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-commit-by-pull-number.js","sourceRoot":"","sources":["../../../../../../src/lib/github/v4/fetchCommits/fetch-commit-by-pull-number.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wCAAwC,CAAC;AAEjE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EA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E,IAAI,EAAE,aAAa,KAAK,WAAW,CAAC,aAAa,CAC5D;QACD,uBAAuB,EAAE,OAAO,KAAK,uBAAuB,EAAE,OAAO,CAAC;IAExE,IAAI,wBAAwB,EAAE,CAAC;QAC7B,MAAM,OAAO,GAAG,MAAM,qCAAqC,CACzD,OAAO,EACP,eAAe,CAAC,OAAO,CAAC,UAAU,CACnC,CAAC;QACF,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,OAAO,CAAC;QACjB,CAAC;IACH,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC;QACpC,GAAG,OAAO;QACV,GAAG,EAAE,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC;KAC7B,CAAC,CAAC;IACH,OAAO,CAAC,MAAM,CAAC,CAAC;AAClB,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ValidConfigOptions } from '../../../../options/options.js';
|
|
2
2
|
import type { Commit } from '../../../sourceCommit/parse-source-commit.js';
|
|
3
3
|
export declare function fetchCommitBySha(options: {
|
|
4
|
-
|
|
4
|
+
githubToken: string;
|
|
5
5
|
branchLabelMapping?: ValidConfigOptions['branchLabelMapping'];
|
|
6
6
|
githubApiBaseUrlV4?: string;
|
|
7
7
|
repoName: string;
|
|
@@ -4,7 +4,7 @@ import { isMissingConfigFileException } from '../../../remote-config.js';
|
|
|
4
4
|
import { parseSourceCommit } from '../../../sourceCommit/parse-source-commit.js';
|
|
5
5
|
import { graphqlRequest } from '../client/graphql-client.js';
|
|
6
6
|
export async function fetchCommitBySha(options) {
|
|
7
|
-
const {
|
|
7
|
+
const { githubToken, githubApiBaseUrlV4 = 'https://api.github.com/graphql', repoName, repoOwner, sha, sourceBranch, } = options;
|
|
8
8
|
const query = graphql(`
|
|
9
9
|
query CommitsBySha($repoOwner: String!, $repoName: String!, $sha: String!) {
|
|
10
10
|
repository(owner: $repoOwner, name: $repoName) {
|
|
@@ -16,7 +16,7 @@ export async function fetchCommitBySha(options) {
|
|
|
16
16
|
}
|
|
17
17
|
`);
|
|
18
18
|
const variables = { repoOwner, repoName, sha };
|
|
19
|
-
const result = await graphqlRequest({
|
|
19
|
+
const result = await graphqlRequest({ githubToken, githubApiBaseUrlV4 }, query, variables);
|
|
20
20
|
if (result.error && !isMissingConfigFileException(result)) {
|
|
21
21
|
throw new BackportError({
|
|
22
22
|
code: 'github-api-exception',
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { ValidConfigOptions } from '../../../../options/options.js';
|
|
2
2
|
import type { Commit } from '../../../sourceCommit/parse-source-commit.js';
|
|
3
3
|
export declare function fetchCommitsByAuthor(options: {
|
|
4
|
-
|
|
4
|
+
githubToken: string;
|
|
5
5
|
author: string | null;
|
|
6
6
|
branchLabelMapping?: ValidConfigOptions['branchLabelMapping'];
|
|
7
7
|
commitPaths?: string[];
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
since: string | null;
|
|
9
|
+
until: string | null;
|
|
10
10
|
githubApiBaseUrlV4?: string;
|
|
11
|
-
|
|
11
|
+
maxCount?: number;
|
|
12
12
|
onlyMissing?: boolean;
|
|
13
13
|
repoName: string;
|
|
14
14
|
repoOwner: string;
|
|
@@ -8,14 +8,14 @@ import { parseSourceCommit } from '../../../sourceCommit/parse-source-commit.js'
|
|
|
8
8
|
import { graphqlRequest } from '../client/graphql-client.js';
|
|
9
9
|
import { fetchAuthorId } from '../fetch-author-id.js';
|
|
10
10
|
async function fetchByCommitPath({ options, authorId, commitPath, }) {
|
|
11
|
-
const {
|
|
11
|
+
const { githubToken, since, until, githubApiBaseUrlV4 = 'https://api.github.com/graphql', maxCount = 10, repoName, repoOwner, sourceBranch, } = options;
|
|
12
12
|
const query = graphql(`
|
|
13
13
|
query CommitsByAuthor(
|
|
14
14
|
$authorId: ID
|
|
15
15
|
$commitPath: String
|
|
16
|
-
$
|
|
17
|
-
$
|
|
18
|
-
$
|
|
16
|
+
$since: GitTimestamp
|
|
17
|
+
$until: GitTimestamp
|
|
18
|
+
$maxCount: Int!
|
|
19
19
|
$repoName: String!
|
|
20
20
|
$repoOwner: String!
|
|
21
21
|
$sourceBranch: String!
|
|
@@ -26,11 +26,11 @@ async function fetchByCommitPath({ options, authorId, commitPath, }) {
|
|
|
26
26
|
... on Commit {
|
|
27
27
|
__typename
|
|
28
28
|
history(
|
|
29
|
-
first: $
|
|
29
|
+
first: $maxCount
|
|
30
30
|
author: { id: $authorId }
|
|
31
31
|
path: $commitPath
|
|
32
|
-
since: $
|
|
33
|
-
until: $
|
|
32
|
+
since: $since
|
|
33
|
+
until: $until
|
|
34
34
|
) {
|
|
35
35
|
edges {
|
|
36
36
|
node {
|
|
@@ -49,18 +49,18 @@ async function fetchByCommitPath({ options, authorId, commitPath, }) {
|
|
|
49
49
|
repoOwner,
|
|
50
50
|
repoName,
|
|
51
51
|
sourceBranch,
|
|
52
|
-
|
|
52
|
+
maxCount,
|
|
53
53
|
authorId,
|
|
54
54
|
commitPath,
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
since,
|
|
56
|
+
until,
|
|
57
57
|
};
|
|
58
|
-
const result = await graphqlRequest({
|
|
58
|
+
const result = await graphqlRequest({ githubToken, githubApiBaseUrlV4 }, query, variables);
|
|
59
59
|
if (result.error) {
|
|
60
|
-
if (result.statusCode === 502 &&
|
|
60
|
+
if (result.statusCode === 502 && maxCount > 50) {
|
|
61
61
|
throw new BackportError({
|
|
62
62
|
code: 'github-api-exception',
|
|
63
|
-
message: `The GitHub API returned a 502 error. Try reducing the number of commits to display: "--max-
|
|
63
|
+
message: `The GitHub API returned a 502 error. Try reducing the number of commits to display: "--max-count 20" (or "-n 20")`,
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
66
|
if (!isMissingConfigFileException(result)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-commits-by-author.js","sourceRoot":"","sources":["../../../../../../src/lib/github/v4/fetchCommits/fetch-commits-by-author.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,O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,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,6BAA6B,WAAW,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QAE5E,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM;YAC9B,CAAC,CAAC,4BAA4B,OAAO,CAAC,MAAM,uBAAuB,QAAQ,2GAA2G;YACtL,CAAC,CAAC,0CAA0C,QAAQ,EAAE,CAAC;QAEzD,MAAM,IAAI,aAAa,CAAC;YACtB,IAAI,EAAE,4BAA4B;YAClC,OAAO,EAAE,SAAS;SACnB,CAAC,CAAC;IACL,CAAC;IAED,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IACjE,MAAM,aAAa,GAAG,OAAO,CAC3B,aAAa,EACb,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,aAAa,EACnC,MAAM,CACP,CAAC;IAEF,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;QACxB,OAAO,aAAa,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC;IACrD,CAAC;IAED,OAAO,aAAa,CAAC;AACvB,CAAC"}
|
|
@@ -4,16 +4,16 @@ import { BackportError } from '../../../backport-error.js';
|
|
|
4
4
|
import { graphqlRequest } from '../client/graphql-client.js';
|
|
5
5
|
import { fetchCommitBySha } from './fetch-commit-by-sha.js';
|
|
6
6
|
export async function fetchCommitsForRebaseAndMergeStrategy(options, commitsTotalCount) {
|
|
7
|
-
const {
|
|
7
|
+
const { githubToken, githubApiBaseUrlV4 = 'https://api.github.com/graphql', pullNumber, repoName, repoOwner, } = options;
|
|
8
8
|
const query = graphql(`
|
|
9
9
|
query CommitsForRebaseAndMergeStrategy(
|
|
10
10
|
$repoOwner: String!
|
|
11
11
|
$repoName: String!
|
|
12
|
-
$
|
|
12
|
+
$pr: Int!
|
|
13
13
|
$commitsTotalCount: Int!
|
|
14
14
|
) {
|
|
15
15
|
repository(owner: $repoOwner, name: $repoName) {
|
|
16
|
-
pullRequest(number: $
|
|
16
|
+
pullRequest(number: $pr) {
|
|
17
17
|
number
|
|
18
18
|
commits(first: $commitsTotalCount) {
|
|
19
19
|
totalCount
|
|
@@ -49,8 +49,8 @@ export async function fetchCommitsForRebaseAndMergeStrategy(options, commitsTota
|
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
`);
|
|
52
|
-
const variables = { repoOwner, repoName, pullNumber, commitsTotalCount };
|
|
53
|
-
const result = await graphqlRequest({
|
|
52
|
+
const variables = { repoOwner, repoName, pr: pullNumber, commitsTotalCount };
|
|
53
|
+
const result = await graphqlRequest({ githubToken, githubApiBaseUrlV4 }, query, variables);
|
|
54
54
|
if (result.error) {
|
|
55
55
|
throw new BackportError({
|
|
56
56
|
code: 'github-api-exception',
|
|
@@ -74,7 +74,9 @@ export async function fetchCommitsForRebaseAndMergeStrategy(options, commitsTota
|
|
|
74
74
|
return hasSameCommittedDate && hasSameCommitMessages && hasSamePullNumber;
|
|
75
75
|
});
|
|
76
76
|
if (didUseRebaseAndMergeStrategy) {
|
|
77
|
-
const commits = await Promise.all(commitsInBaseBranch
|
|
77
|
+
const commits = await Promise.all(commitsInBaseBranch
|
|
78
|
+
.filter((c) => c?.node?.oid != null)
|
|
79
|
+
.map((c) => fetchCommitBySha({ ...options, sha: String(c.node.oid) })));
|
|
78
80
|
return commits;
|
|
79
81
|
}
|
|
80
82
|
}
|
package/dist/src/lib/github/v4/fetchCommits/fetch-commits-for-rebase-and-merge-strategy.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-commits-for-rebase-and-merge-strategy.js","sourceRoot":"","sources":["../../../../../../src/lib/github/v4/fetchCommits/fetch-commits-for-rebase-and-merge-strategy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,OAAO,EAAE,MAAM,wCAAwC,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D,MAAM,CAAC,KAAK,UAAU,qCAAqC,CACzD,OAOC,EACD,iBAAyB;IAEzB,MAAM,EACJ,WAAW,EACX,kBAAkB,GAAG,gCAAgC,EACrD,UAAU,EACV,QAAQ,EACR,SAAS,GACV,GAAG,OAAO,CAAC;IAEZ,MAAM,KAAK,GAAG,OAAO,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CrB,CAAC,CAAC;IAEH,MAAM,SAAS,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,iBAAiB,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"fetch-commits-for-rebase-and-merge-strategy.js","sourceRoot":"","sources":["../../../../../../src/lib/github/v4/fetchCommits/fetch-commits-for-rebase-and-merge-strategy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,OAAO,EAAE,MAAM,wCAAwC,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D,MAAM,CAAC,KAAK,UAAU,qCAAqC,CACzD,OAOC,EACD,iBAAyB;IAEzB,MAAM,EACJ,WAAW,EACX,kBAAkB,GAAG,gCAAgC,EACrD,UAAU,EACV,QAAQ,EACR,SAAS,GACV,GAAG,OAAO,CAAC;IAEZ,MAAM,KAAK,GAAG,OAAO,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CrB,CAAC,CAAC;IAEH,MAA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AM,CAAC,OAAO,CAAC;QAExE,MAAM,iBAAiB,GACrB,KAAK,CAAC,CAAC,EAAE,IAAI,EAAE,sBAAsB,EAAE,KAAK,CAAC,EAAE,IAAI,EAAE,MAAM;YAC3D,eAAe,CAAC,MAAM,CAAC;QAEzB,OAAO,oBAAoB,IAAI,qBAAqB,IAAI,iBAAiB,CAAC;IAC5E,CAAC,CAAC,CAAC;IAEH,IAAI,4BAA4B,EAAE,CAAC;QACjC,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,CAC/B,mBAAmB;aAChB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,IAAI,IAAI,CAAC;aACnC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CACT,gBAAgB,CAAC,EAAE,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,CAAC,CAAE,CAAC,IAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAC5D,CACJ,CAAC;QAEF,OAAO,OAAO,CAAC;IACjB,CAAC;AACH,CAAC"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { Commit } from '../../../sourceCommit/parse-source-commit.js';
|
|
2
2
|
export declare function fetchPullRequestsBySearchQuery(options: {
|
|
3
|
-
|
|
3
|
+
githubToken: string;
|
|
4
4
|
author: string | null;
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
since: string | null;
|
|
6
|
+
until: string | null;
|
|
7
7
|
githubApiBaseUrlV4?: string;
|
|
8
|
-
|
|
8
|
+
maxCount?: number;
|
|
9
9
|
onlyMissing?: boolean;
|
|
10
|
-
|
|
10
|
+
prQuery: string;
|
|
11
11
|
repoName: string;
|
|
12
12
|
repoOwner: string;
|
|
13
13
|
sourceBranch: string;
|
|
@@ -7,10 +7,10 @@ import { isMissingConfigFileException } from '../../../remote-config.js';
|
|
|
7
7
|
import { parseSourceCommit } from '../../../sourceCommit/parse-source-commit.js';
|
|
8
8
|
import { graphqlRequest } from '../client/graphql-client.js';
|
|
9
9
|
export async function fetchPullRequestsBySearchQuery(options) {
|
|
10
|
-
const {
|
|
10
|
+
const { githubToken, author, since, until, githubApiBaseUrlV4 = 'https://api.github.com/graphql', maxCount = 10, prQuery, repoName, repoOwner, sourceBranch, } = options;
|
|
11
11
|
const query = graphql(`
|
|
12
|
-
query PullRequestBySearchQuery($query: String!, $
|
|
13
|
-
search(query: $query, type: ISSUE, first: $
|
|
12
|
+
query PullRequestBySearchQuery($query: String!, $maxCount: Int!) {
|
|
13
|
+
search(query: $query, type: ISSUE, first: $maxCount) {
|
|
14
14
|
nodes {
|
|
15
15
|
... on PullRequest {
|
|
16
16
|
__typename
|
|
@@ -24,14 +24,14 @@ export async function fetchPullRequestsBySearchQuery(options) {
|
|
|
24
24
|
}
|
|
25
25
|
`);
|
|
26
26
|
function dateFilter() {
|
|
27
|
-
if (
|
|
28
|
-
return [`merged:${
|
|
27
|
+
if (until && since) {
|
|
28
|
+
return [`merged:${since}..${until}`];
|
|
29
29
|
}
|
|
30
|
-
if (
|
|
31
|
-
return [`merged:<${
|
|
30
|
+
if (until) {
|
|
31
|
+
return [`merged:<${until}`];
|
|
32
32
|
}
|
|
33
|
-
if (
|
|
34
|
-
return [`merged:>${
|
|
33
|
+
if (since) {
|
|
34
|
+
return [`merged:>${since}`];
|
|
35
35
|
}
|
|
36
36
|
return [];
|
|
37
37
|
}
|
|
@@ -41,15 +41,15 @@ export async function fetchPullRequestsBySearchQuery(options) {
|
|
|
41
41
|
'sort:created-desc',
|
|
42
42
|
`repo:${repoOwner}/${repoName}`,
|
|
43
43
|
...(options.author ? [`author:${options.author}`] : []),
|
|
44
|
-
...(
|
|
44
|
+
...(prQuery.includes('base:') ? [] : [`base:${sourceBranch}`]),
|
|
45
45
|
...dateFilter(),
|
|
46
|
-
|
|
46
|
+
prQuery,
|
|
47
47
|
].join(' ');
|
|
48
48
|
const variables = {
|
|
49
49
|
query: searchQuery,
|
|
50
|
-
|
|
50
|
+
maxCount,
|
|
51
51
|
};
|
|
52
|
-
const result = await graphqlRequest({
|
|
52
|
+
const result = await graphqlRequest({ githubToken, githubApiBaseUrlV4 }, query, variables);
|
|
53
53
|
if (result.error && !isMissingConfigFileException(result)) {
|
|
54
54
|
throw new BackportError({
|
|
55
55
|
code: 'github-api-exception',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-pull-requests-by-search-query.js","sourceRoot":"","sources":["../../../../../../src/lib/github/v4/fetchCommits/fetch-pull-requests-by-search-query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,wCAAwC,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AACrF,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AAEzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,8CAA8C,CAAC;AACjF,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE7D,MAAM,CAAC,KAAK,UAAU,8BAA8B,CAAC,OAYpD;IACC,MAAM,EACJ,WAAW,EACX,MAAM,EACN,
|
|
1
|
+
{"version":3,"file":"fetch-pull-requests-by-search-query.js","sourceRoot":"","sources":["../../../../../../src/lib/github/v4/fetchCommits/fetch-pull-requests-by-search-query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,wCAAwC,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AACrF,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC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AAC;IAC/C,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { OperationResultWithMeta } from './client/graphql-client.js';
|
|
2
|
-
export declare function
|
|
2
|
+
export declare function getInvalidGithubTokenMessage({ result, repoOwner, repoName, globalConfigFile, githubToken, }: {
|
|
3
3
|
result: OperationResultWithMeta;
|
|
4
4
|
repoOwner: string;
|
|
5
5
|
repoName: string;
|
|
6
6
|
globalConfigFile?: string;
|
|
7
|
+
githubToken?: string;
|
|
7
8
|
}): string | undefined;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isEmpty, difference } from 'lodash-es';
|
|
2
2
|
import { getGlobalConfigPath } from '../../env.js';
|
|
3
3
|
import { logger } from '../../logger.js';
|
|
4
|
-
export function
|
|
4
|
+
export function getInvalidGithubTokenMessage({ result, repoOwner, repoName, globalConfigFile, githubToken, }) {
|
|
5
5
|
function getSSOAuthUrl(ssoHeader) {
|
|
6
6
|
const matches = ssoHeader?.match(/url=(.*)/);
|
|
7
7
|
if (matches) {
|
|
@@ -21,7 +21,7 @@ export function getInvalidAccessTokenMessage({ result, repoOwner, repoName, glob
|
|
|
21
21
|
const hasRequiredScopes = isEmpty(difference(requiredScopes.split(',').map((s) => s.trim()), grantedScopes.split(',').map((s) => s.trim())));
|
|
22
22
|
// user does not have permission to the repo
|
|
23
23
|
if (!hasRequiredScopes) {
|
|
24
|
-
return `You do not have access to the repository "${repoOwner}/${repoName}". Please make sure your
|
|
24
|
+
return `You do not have access to the repository "${repoOwner}/${repoName}". Please make sure your GitHub token has the required scopes.\n\nRequired scopes: ${requiredScopes}\nGranted scopes: ${grantedScopes}`;
|
|
25
25
|
}
|
|
26
26
|
// repo does not exist
|
|
27
27
|
return `The repository "${repoOwner}/${repoName}" doesn't exist`;
|
|
@@ -30,12 +30,16 @@ export function getInvalidAccessTokenMessage({ result, repoOwner, repoName, glob
|
|
|
30
30
|
const ssoAuthUrl = getSSOAuthUrl(ssoHeader);
|
|
31
31
|
// user does not have permissions
|
|
32
32
|
if (repoAccessForbidden && ssoAuthUrl) {
|
|
33
|
-
return `Please follow the link to authorize your
|
|
33
|
+
return `Please follow the link to authorize your GitHub token with SSO:\n\n${ssoAuthUrl}`;
|
|
34
34
|
}
|
|
35
35
|
break;
|
|
36
36
|
}
|
|
37
37
|
case 401: {
|
|
38
|
-
|
|
38
|
+
const globalConfigPath = getGlobalConfigPath(globalConfigFile);
|
|
39
|
+
const redactedToken = githubToken
|
|
40
|
+
? `${githubToken.slice(0, 4)}...${githubToken.slice(-4)}`
|
|
41
|
+
: 'undefined';
|
|
42
|
+
return `The GitHub token "${redactedToken}" is invalid. Please make sure your global config (${globalConfigPath}) contains a valid token:\n\n{ "githubToken": "<valid_token>" }`;
|
|
39
43
|
}
|
|
40
44
|
case undefined: {
|
|
41
45
|
logger.warn('Missing status code');
|
|
@@ -47,4 +51,4 @@ export function getInvalidAccessTokenMessage({ result, repoOwner, repoName, glob
|
|
|
47
51
|
}
|
|
48
52
|
}
|
|
49
53
|
}
|
|
50
|
-
//# sourceMappingURL=get-invalid-
|
|
54
|
+
//# sourceMappingURL=get-invalid-github-token-message.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-invalid-github-token-message.js","sourceRoot":"","sources":["../../../../../src/lib/github/v4/get-invalid-github-token-message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAGzC,MAAM,UAAU,4BAA4B,CAAC,EAC3C,MAAM,EACN,SAAS,EACT,QAAQ,EACR,gBAAgB,EAChB,WAAW,GAOZ;IACC,SAAS,aAAa,CAAC,SAAyB;QAC9C,MAAM,OAAO,GAAG,SAAS,EAAE,KAAK,CAAC,UAAU,CAAC,C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AE,CAAC;gBACpN,CAAC;gBAED,sBAAsB;gBACtB,OAAO,mBAAmB,SAAS,IAAI,QAAQ,iBAAiB,CAAC;YACnE,CAAC;YAED,MAAM,mBAAmB,GAAG,aAAa,CAAC,IAAI,CAC5C,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,UAAU,CAAC,YAAY,KAAK,IAAI,CACrD,CAAC;YAEF,MAAM,UAAU,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC;YAE5C,iCAAiC;YACjC,IAAI,mBAAmB,IAAI,UAAU,EAAE,CAAC;gBACtC,OAAO,sEAAsE,UAAU,EAAE,CAAC;YAC5F,CAAC;YACD,MAAM;QACR,CAAC;QAED,KAAK,GAAG,CAAC,CAAC,CAAC;YACT,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;YAC/D,MAAM,aAAa,GAAG,WAAW;gBAC/B,CAAC,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE;gBACzD,CAAC,CAAC,WAAW,CAAC;YAChB,OAAO,qBAAqB,aAAa,sDAAsD,gBAAgB,iEAAiE,CAAC;QACnL,CAAC;QAED,KAAK,SAAS,CAAC,CAAC,CAAC;YACf,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;YACnC,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,OAAO,CAAC,CAAC,CAAC;YACR,MAAM,CAAC,IAAI,CAAC,2BAA2B,UAAU,EAAE,CAAC,CAAC;YACrD,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export declare function getRepoOwnerAndNameFromGitRemotes({
|
|
2
|
-
|
|
1
|
+
export declare function getRepoOwnerAndNameFromGitRemotes({ githubToken, githubApiBaseUrlV4, cwd, }: {
|
|
2
|
+
githubToken: string;
|
|
3
3
|
githubApiBaseUrlV4?: string;
|
|
4
4
|
cwd: string;
|
|
5
5
|
}): Promise<{
|
|
@@ -4,7 +4,7 @@ import { getRepoInfoFromGitRemotes } from '../../git/index.js';
|
|
|
4
4
|
import { logger } from '../../logger.js';
|
|
5
5
|
import { graphqlRequest } from './client/graphql-client.js';
|
|
6
6
|
// This method should be used to get the origin owner (instead of a fork owner)
|
|
7
|
-
export async function getRepoOwnerAndNameFromGitRemotes({
|
|
7
|
+
export async function getRepoOwnerAndNameFromGitRemotes({ githubToken, githubApiBaseUrlV4, cwd, }) {
|
|
8
8
|
const remotes = await getRepoInfoFromGitRemotes({ cwd });
|
|
9
9
|
const firstRemote = remotes.at(0);
|
|
10
10
|
if (!firstRemote) {
|
|
@@ -31,7 +31,7 @@ export async function getRepoOwnerAndNameFromGitRemotes({ accessToken, githubApi
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
`);
|
|
34
|
-
const result = await graphqlRequest({
|
|
34
|
+
const result = await graphqlRequest({ githubToken, githubApiBaseUrlV4 }, query, variables);
|
|
35
35
|
if (result.error) {
|
|
36
36
|
throw new BackportError({
|
|
37
37
|
code: 'github-api-exception',
|