backport 8.9.2 → 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;
@@ -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 })));
@@ -1 +1 @@
1
- export declare const PACKAGE_VERSION = "8.9.2";
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.2';
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.2",
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
  }