backport 8.9.1 → 8.9.3

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/dist/lib/git.js CHANGED
@@ -128,16 +128,8 @@ async function getIsCommitInBranch(options, commitSha) {
128
128
  return true;
129
129
  }
130
130
  catch (e) {
131
- const isSpawnError = e instanceof child_process_promisified_1.SpawnError;
132
- if (isSpawnError) {
133
- const commitNotInBranch = e.context.code === 1 && e.context.stderr === '';
134
- const commitNotExist = e.context.code === 128 &&
135
- e.context.stderr.includes('Not a valid object name');
136
- if (commitNotInBranch || commitNotExist) {
137
- return false;
138
- }
139
- }
140
- throw e;
131
+ logger_1.logger.warn('getIsCommitInBranch threw', e);
132
+ return false;
141
133
  }
142
134
  }
143
135
  exports.getIsCommitInBranch = getIsCommitInBranch;
@@ -70,7 +70,10 @@ function getCommentBody({ options, pullNumber, backportResponse, }) {
70
70
  }
71
71
  const packageVersionSection = `\n<!--- Backport version: ${packageVersion_1.PACKAGE_VERSION} -->`;
72
72
  const manualBackportCommand = `\n### Manual backport\nTo create the backport manually run:\n\`\`\`\n${options.backportBinary} --pr ${pullNumber}\n\`\`\`\n`;
73
- const questionsAndLinkToBackport = '\n### Questions ?\nPlease refer to the [Backport tool documentation](https://github.com/sqren/backport)\n';
73
+ const linkToGithubActionLogs = options.githubActionRunId
74
+ ? ` and see the [Github Action logs](https://github.com/${repoOwner}/${repoName}/actions/runs/${options.githubActionRunId}) for details`
75
+ : '';
76
+ const questionsAndLinkToBackport = `\n### Questions ?\nPlease refer to the [Backport tool documentation](https://github.com/sqren/backport)${linkToGithubActionLogs}\n`;
74
77
  if (backportResponse.status === 'aborted' &&
75
78
  backportResponse.error.errorContext.code === 'no-branches-exception') {
76
79
  return `## ⚪ Backport skipped
@@ -21,8 +21,15 @@ async function fetchCommitsByPullNumber(options) {
21
21
  repository(owner: $repoOwner, name: $repoName) {
22
22
  pullRequest(number: $pullNumber) {
23
23
  # used to determine if "Rebase and Merge" strategy was used
24
- commits {
24
+ commits(last: 1) {
25
25
  totalCount
26
+ edges {
27
+ node {
28
+ commit {
29
+ message
30
+ }
31
+ }
32
+ }
26
33
  }
27
34
 
28
35
  mergeCommit {
@@ -67,9 +74,12 @@ async function fetchCommitsByPullNumber(options) {
67
74
  if (mergeCommit === null) {
68
75
  throw new BackportError_1.BackportError(`The PR #${pullNumber} is not merged`);
69
76
  }
70
- const possiblyRebaseAndMergeStrategy = pullRequestNode.commits.totalCount > 0 &&
71
- mergeCommit.history.edges.every((c) => c.node.committedDate === mergeCommit.committedDate);
72
- if (possiblyRebaseAndMergeStrategy) {
77
+ const lastCommitInPullRequest = pullRequestNode.commits.edges[0].node.commit;
78
+ const firstCommitInBaseBranch = mergeCommit.history.edges[0].node;
79
+ const isRebaseAndMergeStrategy = pullRequestNode.commits.totalCount > 0 &&
80
+ mergeCommit.history.edges.every((c) => c.node.committedDate === mergeCommit.committedDate) &&
81
+ lastCommitInPullRequest.message === firstCommitInBaseBranch.message;
82
+ if (isRebaseAndMergeStrategy) {
73
83
  const commits = await (0, fetchCommitsForRebaseAndMergeStrategy_1.fetchCommitsForRebaseAndMergeStrategy)(options, pullRequestNode.commits.totalCount);
74
84
  if (commits) {
75
85
  return commits;
@@ -10,7 +10,7 @@ const fetchCommitBySha_1 = require("./fetchCommitBySha");
10
10
  async function fetchCommitsForRebaseAndMergeStrategy(options, commitsTotalCount) {
11
11
  const { accessToken, githubApiBaseUrlV4 = 'https://api.github.com/graphql', pullNumber, repoName, repoOwner, } = options;
12
12
  const query = (0, graphql_tag_1.default) `
13
- query CommitByPullNumber(
13
+ query CommitsForRebaseAndMergeStrategy(
14
14
  $repoOwner: String!
15
15
  $repoName: String!
16
16
  $pullNumber: Int!
@@ -18,6 +18,7 @@ async function fetchCommitsForRebaseAndMergeStrategy(options, commitsTotalCount)
18
18
  ) {
19
19
  repository(owner: $repoOwner, name: $repoName) {
20
20
  pullRequest(number: $pullNumber) {
21
+ number
21
22
  commits(first: $commitsTotalCount) {
22
23
  totalCount
23
24
  edges {
@@ -37,6 +38,13 @@ async function fetchCommitsForRebaseAndMergeStrategy(options, commitsTotalCount)
37
38
  oid
38
39
  message
39
40
  committedDate
41
+ associatedPullRequests(first: 1) {
42
+ edges {
43
+ node {
44
+ number
45
+ }
46
+ }
47
+ }
40
48
  }
41
49
  }
42
50
  }
@@ -66,9 +74,11 @@ async function fetchCommitsForRebaseAndMergeStrategy(options, commitsTotalCount)
66
74
  const commitsInPullRequest = pullRequestNode.commits.edges;
67
75
  const commitsInBaseBranch = pullRequestNode.mergeCommit.history.edges.reverse();
68
76
  const didUseRebaseAndMergeStrategy = commitsInBaseBranch.every((c, i) => {
69
- const hasIdenticalCommittedDate = c.node.committedDate === pullRequestNode.mergeCommit?.committedDate;
70
- const hasIdenticalCommitMessages = c.node.message === commitsInPullRequest[i].node.commit.message;
71
- return hasIdenticalCommittedDate && hasIdenticalCommitMessages;
77
+ const hasSameCommittedDate = c.node.committedDate === pullRequestNode.mergeCommit?.committedDate;
78
+ const hasSameCommitMessages = c.node.message === commitsInPullRequest[i].node.commit.message;
79
+ const hasSamePullNumber = c.node.associatedPullRequests.edges[0].node.number ===
80
+ pullRequestNode.number;
81
+ return hasSameCommittedDate && hasSameCommitMessages && hasSamePullNumber;
72
82
  });
73
83
  if (didUseRebaseAndMergeStrategy) {
74
84
  const commits = await Promise.all(commitsInBaseBranch.map((c) => (0, fetchCommitBySha_1.fetchCommitBySha)({ ...options, sha: c.node.oid })));
@@ -31,6 +31,7 @@ export declare function getOptionsFromGithub(options: {
31
31
  gitAuthorEmail?: string | undefined;
32
32
  gitAuthorName?: string | undefined;
33
33
  gitHostname?: string | undefined;
34
+ githubActionRunId?: number | undefined;
34
35
  githubApiBaseUrlV3?: string | undefined;
35
36
  githubApiBaseUrlV4?: string | undefined;
36
37
  interactive?: boolean | undefined;
@@ -55,13 +56,13 @@ export declare function getOptionsFromGithub(options: {
55
56
  resetAuthor?: boolean | undefined;
56
57
  reviewers?: string[] | undefined;
57
58
  sha?: string | string[] | undefined;
59
+ signoff?: boolean | undefined;
58
60
  skipRemoteConfig?: boolean | undefined;
59
61
  sourceBranch: string;
60
62
  sourcePRLabels?: string[] | undefined;
61
63
  targetBranchChoices?: import("../../../../options/ConfigOptions").TargetBranchChoiceOrString[] | undefined;
62
64
  targetBranches?: string[] | undefined;
63
65
  targetPRLabels?: string[] | undefined;
64
- signoff?: boolean | undefined;
65
66
  help?: boolean | undefined;
66
67
  version?: boolean | undefined;
67
68
  v?: boolean | undefined;
@@ -29,6 +29,7 @@ declare type Options = Partial<{
29
29
  gitAuthorEmail: string;
30
30
  gitAuthorName: string;
31
31
  gitHostname: string;
32
+ githubActionRunId: number;
32
33
  githubApiBaseUrlV3: string;
33
34
  githubApiBaseUrlV4: string;
34
35
  interactive: boolean;
@@ -53,13 +54,13 @@ declare type Options = Partial<{
53
54
  resetAuthor: boolean;
54
55
  reviewers: string[];
55
56
  sha: string | string[];
57
+ signoff: boolean;
56
58
  skipRemoteConfig: boolean;
57
59
  sourceBranch: string;
58
60
  sourcePRLabels: string[];
59
61
  targetBranchChoices: TargetBranchChoiceOrString[];
60
62
  targetBranches: string[];
61
63
  targetPRLabels: string[];
62
- signoff: boolean;
63
64
  }>;
64
65
  export declare type ConfigFileOptions = Options & Partial<{
65
66
  help: boolean;
@@ -28,6 +28,7 @@ export declare function getOptionsFromConfigFiles({ optionsFromCliArgs, optionsF
28
28
  gitAuthorEmail?: string | undefined;
29
29
  gitAuthorName?: string | undefined;
30
30
  gitHostname?: string | undefined;
31
+ githubActionRunId?: number | undefined;
31
32
  githubApiBaseUrlV3?: string | undefined;
32
33
  githubApiBaseUrlV4?: string | undefined;
33
34
  interactive?: boolean | undefined;
@@ -52,13 +53,13 @@ export declare function getOptionsFromConfigFiles({ optionsFromCliArgs, optionsF
52
53
  resetAuthor?: boolean | undefined;
53
54
  reviewers?: string[] | undefined;
54
55
  sha?: string | string[] | undefined;
56
+ signoff?: boolean | undefined;
55
57
  skipRemoteConfig?: boolean | undefined;
56
58
  sourceBranch?: string | undefined;
57
59
  sourcePRLabels?: string[] | undefined;
58
60
  targetBranchChoices?: import("../ConfigOptions").TargetBranchChoiceOrString[] | undefined;
59
61
  targetBranches?: string[] | undefined;
60
62
  targetPRLabels?: string[] | undefined;
61
- signoff?: boolean | undefined;
62
63
  help?: boolean | undefined;
63
64
  version?: boolean | undefined;
64
65
  v?: boolean | undefined;
@@ -58,5 +58,6 @@ export declare function withConfigMigrations({ upstream, labels, branches, ...co
58
58
  targetBranch: string;
59
59
  }) => boolean | Promise<boolean>) | undefined;
60
60
  backportBinary?: string | undefined;
61
+ githubActionRunId?: number | undefined;
61
62
  branchLabelMapping?: Record<string, string> | undefined;
62
63
  };
@@ -94,6 +94,7 @@ export declare function getOptions({ optionsFromCliArgs, optionsFromModule, }: {
94
94
  targetBranch: string;
95
95
  }) => boolean | Promise<boolean>) | undefined;
96
96
  backportBinary: string;
97
+ githubActionRunId?: number | undefined;
97
98
  multiple?: boolean | undefined;
98
99
  help?: boolean | undefined;
99
100
  version?: boolean | undefined;
@@ -1 +1 @@
1
- export declare const PACKAGE_VERSION = "8.9.1";
1
+ export declare const PACKAGE_VERSION = "8.9.3";
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PACKAGE_VERSION = void 0;
4
- exports.PACKAGE_VERSION = '8.9.1';
4
+ exports.PACKAGE_VERSION = '8.9.3';
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "branches",
15
15
  "branching"
16
16
  ],
17
- "version": "8.9.1",
17
+ "version": "8.9.3",
18
18
  "main": "./dist/entrypoint.module.js",
19
19
  "types": "dist/entrypoint.module.d.ts",
20
20
  "bin": {
@@ -87,29 +87,29 @@
87
87
  "@types/core-js": "^2.5.5",
88
88
  "@types/dedent": "^0.7.0",
89
89
  "@types/inquirer": "^8.2.1",
90
- "@types/jest": "^28.1.4",
90
+ "@types/jest": "^28.1.6",
91
91
  "@types/lodash": "^4.14.182",
92
- "@types/node": "^18.0.3",
92
+ "@types/node": "^18.6.3",
93
93
  "@types/safe-json-stringify": "^1.1.2",
94
94
  "@types/yargs": "^17.0.10",
95
95
  "@types/yargs-parser": "^21.0.0",
96
- "@typescript-eslint/eslint-plugin": "^5.30.6",
97
- "@typescript-eslint/parser": "^5.30.6",
98
- "eslint": "^8.19.0",
96
+ "@typescript-eslint/eslint-plugin": "^5.32.0",
97
+ "@typescript-eslint/parser": "^5.32.0",
98
+ "eslint": "^8.21.0",
99
99
  "eslint-config-prettier": "^8.5.0",
100
100
  "eslint-plugin-import": "^2.26.0",
101
- "eslint-plugin-jest": "^26.5.3",
101
+ "eslint-plugin-jest": "^26.7.0",
102
102
  "eslint-plugin-prettier": "^4.2.1",
103
- "graphql-config": "^4.3.1",
103
+ "graphql-config": "^4.3.3",
104
104
  "husky": "^8.0.1",
105
- "jest": "^28.1.2",
105
+ "jest": "^28.1.3",
106
106
  "jest-snapshot-serializer-ansi": "^1.0.0",
107
107
  "lint-staged": "^13.0.3",
108
- "nock": "^13.2.8",
108
+ "nock": "^13.2.9",
109
109
  "prettier": "^2.7.1",
110
110
  "strip-ansi": "^6.0.1",
111
- "ts-jest": "^28.0.5",
112
- "ts-node": "^10.8.2",
111
+ "ts-jest": "^28.0.7",
112
+ "ts-node": "^10.9.1",
113
113
  "typescript": "^4.7.4"
114
114
  }
115
115
  }