backport 6.1.3 → 6.1.4

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.
Files changed (48) hide show
  1. package/dist/entrypoint.module.d.ts +2 -0
  2. package/dist/entrypoint.module.js +5 -1
  3. package/dist/entrypoint.module.private.test.js +4 -1
  4. package/dist/main.js +1 -1
  5. package/dist/options/cliArgs.d.ts +2 -0
  6. package/dist/options/cliArgs.js +14 -1
  7. package/dist/options/config/globalConfig.js +1 -1
  8. package/dist/options/options.d.ts +4 -0
  9. package/dist/options/options.js +3 -1
  10. package/dist/options/options.test.js +3 -1
  11. package/dist/runSequentially.test.js +7 -5
  12. package/dist/services/HandledError.d.ts +1 -1
  13. package/dist/services/git.d.ts +2 -1
  14. package/dist/services/git.js +4 -2
  15. package/dist/services/github/v3/createPullRequest.test.js +3 -3
  16. package/dist/services/github/v3/createStatusComment.d.ts +1 -1
  17. package/dist/services/github/v3/createStatusComment.js +31 -11
  18. package/dist/services/github/v3/createStatusComment.test.js +139 -86
  19. package/dist/services/github/v4/fetchCommits/allFetchers.private.test.d.ts +1 -0
  20. package/dist/services/github/v4/fetchCommits/allFetchers.private.test.js +78 -0
  21. package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.js +1 -1
  22. package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +64 -0
  23. package/dist/services/github/v4/fetchCommits/fetchCommitBySha.js +5 -5
  24. package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +60 -0
  25. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.d.ts +2 -0
  26. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +17 -10
  27. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +72 -0
  28. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.js +6 -0
  29. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.js +8 -7
  30. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +8 -0
  31. package/dist/services/github/v4/mocks/commitsByAuthorMock.js +16 -5
  32. package/dist/services/sourceCommit/getExpectedTargetPullRequests.d.ts +4 -0
  33. package/dist/services/sourceCommit/getExpectedTargetPullRequests.js +8 -2
  34. package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.js +20 -0
  35. package/dist/services/sourceCommit/getMockSourceCommit.d.ts +1 -0
  36. package/dist/services/sourceCommit/getMockSourceCommit.js +72 -46
  37. package/dist/services/sourceCommit/parseSourceCommit.d.ts +22 -8
  38. package/dist/services/sourceCommit/parseSourceCommit.js +29 -10
  39. package/dist/services/sourceCommit/parseSourceCommit.test.js +10 -2
  40. package/dist/test/integration/integration.private.test.js +2 -2
  41. package/dist/test/nockHelpers.js +1 -3
  42. package/dist/test/setupFiles/automatic-mocks.js +1 -0
  43. package/dist/ui/cherrypickAndCreateTargetPullRequest.js +3 -2
  44. package/dist/ui/cherrypickAndCreateTargetPullRequest.test.js +6 -4
  45. package/dist/ui/getCommits.js +1 -1
  46. package/dist/ui/getCommitsWithoutBackports.js +17 -2
  47. package/package.json +3 -3
  48. package/yarn.lock +462 -284
@@ -8,7 +8,7 @@ const parseSourceCommit_1 = require("../../../sourceCommit/parseSourceCommit");
8
8
  const apiRequestV4_1 = require("../apiRequestV4");
9
9
  const fetchAuthorId_1 = require("../fetchAuthorId");
10
10
  function fetchByCommitPath({ options, authorId, commitPath, }) {
11
- const { accessToken, githubApiBaseUrlV4 = 'https://api.github.com/graphql', maxNumber = 10, repoName, repoOwner, sourceBranch, } = options;
11
+ const { accessToken, githubApiBaseUrlV4 = 'https://api.github.com/graphql', maxNumber = 10, repoName, repoOwner, sourceBranch, dateSince, dateUntil, } = options;
12
12
  const query = /* GraphQL */ `
13
13
  query CommitsByAuthor(
14
14
  $repoOwner: String!
@@ -17,6 +17,8 @@ function fetchByCommitPath({ options, authorId, commitPath, }) {
17
17
  $sourceBranch: String!
18
18
  $authorId: ID
19
19
  $commitPath: String
20
+ $dateSince: GitTimestamp
21
+ $dateUntil: GitTimestamp
20
22
  ) {
21
23
  repository(owner: $repoOwner, name: $repoName) {
22
24
  ref(qualifiedName: $sourceBranch) {
@@ -26,10 +28,12 @@ function fetchByCommitPath({ options, authorId, commitPath, }) {
26
28
  first: $maxNumber
27
29
  author: { id: $authorId }
28
30
  path: $commitPath
31
+ since: $dateSince
32
+ until: $dateUntil
29
33
  ) {
30
34
  edges {
31
35
  node {
32
- ...${parseSourceCommit_1.sourceCommitWithTargetPullRequestFragment.name}
36
+ ...SourceCommitWithTargetPullRequest
33
37
  }
34
38
  }
35
39
  }
@@ -41,18 +45,21 @@ function fetchByCommitPath({ options, authorId, commitPath, }) {
41
45
 
42
46
  ${parseSourceCommit_1.sourceCommitWithTargetPullRequestFragment.source}
43
47
  `;
48
+ const variables = {
49
+ repoOwner,
50
+ repoName,
51
+ sourceBranch,
52
+ maxNumber,
53
+ authorId,
54
+ commitPath,
55
+ dateSince,
56
+ dateUntil,
57
+ };
44
58
  return (0, apiRequestV4_1.apiRequestV4)({
45
59
  githubApiBaseUrlV4,
46
60
  accessToken,
47
61
  query,
48
- variables: {
49
- repoOwner,
50
- repoName,
51
- sourceBranch,
52
- maxNumber,
53
- authorId,
54
- commitPath,
55
- },
62
+ variables,
56
63
  });
57
64
  }
58
65
  async function fetchCommitsByAuthor(options) {
@@ -1,12 +1,72 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ var __importDefault = (this && this.__importDefault) || function (mod) {
22
+ return (mod && mod.__esModule) ? mod : { "default": mod };
23
+ };
2
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
+ const graphql_tag_1 = __importDefault(require("graphql-tag"));
3
26
  const getDevAccessToken_1 = require("../../../../test/private/getDevAccessToken");
27
+ const apiRequestV4Module = __importStar(require("../apiRequestV4"));
4
28
  const fetchCommitsByAuthor_1 = require("./fetchCommitsByAuthor");
5
29
  describe('fetchCommitsByAuthor', () => {
6
30
  let devAccessToken;
7
31
  beforeAll(async () => {
8
32
  devAccessToken = await (0, getDevAccessToken_1.getDevAccessToken)();
9
33
  });
34
+ describe('snapshot request/response', () => {
35
+ let spy;
36
+ let commits;
37
+ beforeEach(async () => {
38
+ spy = jest.spyOn(apiRequestV4Module, 'apiRequestV4');
39
+ commits = await (0, fetchCommitsByAuthor_1.fetchCommitsByAuthor)({
40
+ accessToken: devAccessToken,
41
+ author: 'sqren',
42
+ historicalBranchLabelMappings: [],
43
+ maxNumber: 10,
44
+ repoName: 'kibana',
45
+ repoOwner: 'elastic',
46
+ sourceBranch: 'main',
47
+ dateSince: '2021-01-10T00:00:00Z',
48
+ dateUntil: '2022-01-01T00:00:00Z',
49
+ commitPaths: [],
50
+ });
51
+ });
52
+ it('makes the right queries', () => {
53
+ const queries = spy.mock.calls.reduce((acc, call) => {
54
+ const query = call[0].query;
55
+ const ast = (0, graphql_tag_1.default)(query);
56
+ //@ts-expect-error
57
+ const name = ast.definitions[0].name.value;
58
+ return { ...acc, [name]: query };
59
+ }, {});
60
+ const queryNames = Object.keys(queries);
61
+ expect(queryNames).toEqual(['AuthorId', 'CommitsByAuthor']);
62
+ queryNames.forEach((name) => {
63
+ expect(queries[name]).toMatchSnapshot(`Query: ${name}`);
64
+ });
65
+ });
66
+ it('returns the correct response', async () => {
67
+ expect(commits).toMatchSnapshot();
68
+ });
69
+ });
10
70
  describe('commitPaths', () => {
11
71
  const getOptions = () => ({
12
72
  accessToken: devAccessToken,
@@ -16,6 +76,8 @@ describe('fetchCommitsByAuthor', () => {
16
76
  repoName: 'repo-with-different-commit-paths',
17
77
  repoOwner: 'backport-org',
18
78
  sourceBranch: 'main',
79
+ dateSince: null,
80
+ dateUntil: null,
19
81
  });
20
82
  const getCommitMessages = (commits) => {
21
83
  return commits.map((c) => c.originalMessage.replace(/(\r\n|\n|\r)/gm, ''));
@@ -90,6 +152,8 @@ describe('fetchCommitsByAuthor', () => {
90
152
  repoOwner: 'backport-org',
91
153
  sourceBranch: 'master',
92
154
  author: null,
155
+ dateSince: null,
156
+ dateUntil: null,
93
157
  });
94
158
  });
95
159
  it('returns related OPEN PRs', async () => {
@@ -111,12 +175,20 @@ describe('fetchCommitsByAuthor', () => {
111
175
  state: 'MERGED',
112
176
  number: 6,
113
177
  url: 'https://github.com/backport-org/backport-e2e/pull/6',
178
+ mergeCommit: {
179
+ message: 'Add 🍏 emoji (#5) (#6)',
180
+ sha: '4bcd876d4ceaa73cf437bfc89b74d1a4e704c0a6',
181
+ },
114
182
  },
115
183
  {
116
184
  branch: '7.8',
117
185
  state: 'MERGED',
118
186
  number: 7,
119
187
  url: 'https://github.com/backport-org/backport-e2e/pull/7',
188
+ mergeCommit: {
189
+ message: 'Add 🍏 emoji (#5) (#7)',
190
+ sha: '46cd6f9999effdf894a36dbc7db90e890f4be840',
191
+ },
120
192
  },
121
193
  ]);
122
194
  });
@@ -16,6 +16,8 @@ const defaultOptions = {
16
16
  repoName: 'kibana',
17
17
  repoOwner: 'elastic',
18
18
  sourceBranch: 'source-branch-from-options',
19
+ dateSince: null,
20
+ dateUntil: null,
19
21
  };
20
22
  const authorIdMockData = { user: { id: 'myUserId' } };
21
23
  describe('fetchCommitsByAuthor', () => {
@@ -72,6 +74,10 @@ describe('fetchCommitsByAuthor', () => {
72
74
  state: 'MERGED',
73
75
  number: 99,
74
76
  url: 'https://github.com/elastic/kibana/pull/99',
77
+ mergeCommit: {
78
+ message: 'Add SF mention (#80)\n\n* Add SF mention\r\n\r\n* Add several emojis!',
79
+ sha: 'target-merge-commit-sha',
80
+ },
75
81
  },
76
82
  ],
77
83
  sourceBranch: 'master',
@@ -13,7 +13,7 @@ async function fetchPullRequestBySearchQuery(options) {
13
13
  nodes {
14
14
  ... on PullRequest {
15
15
  mergeCommit {
16
- ...${parseSourceCommit_1.sourceCommitWithTargetPullRequestFragment.name}
16
+ ...SourceCommitWithTargetPullRequest
17
17
  }
18
18
  }
19
19
  }
@@ -22,16 +22,17 @@ async function fetchPullRequestBySearchQuery(options) {
22
22
 
23
23
  ${parseSourceCommit_1.sourceCommitWithTargetPullRequestFragment.source}
24
24
  `;
25
- const authorFilter = author ? `author:${author}` : '';
26
- const searchQuery = `type:pr is:merged sort:updated-desc repo:${repoOwner}/${repoName} ${authorFilter} ${prFilter} base:${sourceBranch}`;
25
+ const authorFilter = author ? ` author:${author}` : '';
26
+ const searchQuery = `type:pr is:merged sort:updated-desc repo:${repoOwner}/${repoName}${authorFilter} ${prFilter} base:${sourceBranch}`;
27
+ const variables = {
28
+ query: searchQuery,
29
+ maxNumber: maxNumber,
30
+ };
27
31
  const res = await (0, apiRequestV4_1.apiRequestV4)({
28
32
  githubApiBaseUrlV4,
29
33
  accessToken,
30
34
  query,
31
- variables: {
32
- query: searchQuery,
33
- maxNumber: maxNumber,
34
- },
35
+ variables,
35
36
  });
36
37
  const commits = res.search.nodes.map((pullRequestNode) => {
37
38
  const sourceCommit = pullRequestNode.mergeCommit;
@@ -57,12 +57,20 @@ describe('fetchPullRequestBySearchQuery', () => {
57
57
  state: 'MERGED',
58
58
  number: 6,
59
59
  url: 'https://github.com/backport-org/backport-e2e/pull/6',
60
+ mergeCommit: {
61
+ message: 'Add 🍏 emoji (#5) (#6)',
62
+ sha: '4bcd876d4ceaa73cf437bfc89b74d1a4e704c0a6',
63
+ },
60
64
  },
61
65
  {
62
66
  branch: '7.8',
63
67
  state: 'MERGED',
64
68
  number: 7,
65
69
  url: 'https://github.com/backport-org/backport-e2e/pull/7',
70
+ mergeCommit: {
71
+ message: 'Add 🍏 emoji (#5) (#7)',
72
+ sha: '46cd6f9999effdf894a36dbc7db90e890f4be840',
73
+ },
66
74
  },
67
75
  ],
68
76
  originalMessage: 'Add 🍏 emoji (#5)',
@@ -40,6 +40,10 @@ exports.commitsByAuthorMock = {
40
40
  nodes: [{ name: 'my-label-b' }],
41
41
  },
42
42
  number: 85,
43
+ sourceMergeCommit: {
44
+ oid: 'f3b618b9421fdecdb36862f907afbdd6344b361d',
45
+ message: 'Add witch (#85)',
46
+ },
43
47
  timelineItems: {
44
48
  edges: [],
45
49
  },
@@ -68,12 +72,24 @@ exports.commitsByAuthorMock = {
68
72
  },
69
73
  baseRefName: 'master',
70
74
  number: 80,
75
+ sourceMergeCommit: {
76
+ oid: '79cf18453ec32a4677009dcbab1c9c8c73fc14fe',
77
+ message: 'Add SF mention (#80)\n\n* Add SF mention\r\n\r\n* Add several emojis!',
78
+ },
71
79
  timelineItems: {
72
80
  edges: [
73
81
  {
74
82
  node: {
75
83
  targetPullRequest: {
76
84
  __typename: 'PullRequest',
85
+ targetMergeCommit: {
86
+ oid: 'target-merge-commit-sha',
87
+ message: 'Add SF mention (#80)\n\n* Add SF mention\r\n\r\n* Add several emojis!',
88
+ },
89
+ repository: {
90
+ name: 'kibana',
91
+ owner: { login: 'elastic' },
92
+ },
77
93
  url: 'https://github.com/elastic/kibana/pull/99',
78
94
  title: 'some title',
79
95
  state: 'MERGED',
@@ -84,11 +100,6 @@ exports.commitsByAuthorMock = {
84
100
  {
85
101
  node: {
86
102
  targetCommit: {
87
- repository: {
88
- name: 'kibana',
89
- owner: { login: 'elastic' },
90
- },
91
- committedDate: '2021-12-23T00:00:00Z',
92
103
  oid: 'abc',
93
104
  message: 'Add SF mention (#80)\n\n* Add SF mention\r\n\r\n* Add several emojis!',
94
105
  },
@@ -5,5 +5,9 @@ export declare type ExpectedTargetPullRequest = {
5
5
  number?: number;
6
6
  branch: string;
7
7
  state: 'OPEN' | 'CLOSED' | 'MERGED' | 'MISSING';
8
+ mergeCommit?: {
9
+ sha: string;
10
+ message: string;
11
+ };
8
12
  };
9
13
  export declare function getExpectedTargetPullRequests(sourceCommit: SourceCommitWithTargetPullRequest, branchLabelMapping: ValidConfigOptions['branchLabelMapping']): ExpectedTargetPullRequest[];
@@ -34,9 +34,9 @@ function getExistingTargetPullRequests(sourceCommit, sourcePullRequest) {
34
34
  // at least one of the commits in `targetPullRequest` should match the merge commit from the source pull request
35
35
  const didCommitMatch = targetPullRequest.commits.edges.some((commitEdge) => {
36
36
  const { targetCommit } = commitEdge.node;
37
- const matchingRepoName = sourceCommit.repository.name === targetCommit.repository.name;
37
+ const matchingRepoName = sourceCommit.repository.name === targetPullRequest.repository.name;
38
38
  const matchingRepoOwner = sourceCommit.repository.owner.login ===
39
- targetCommit.repository.owner.login;
39
+ targetPullRequest.repository.owner.login;
40
40
  const targetCommitMessage = (0, commitFormatters_1.getFirstLine)(targetCommit.message);
41
41
  const matchingMessage = targetCommitMessage === sourceCommitMessage;
42
42
  return matchingRepoName && matchingRepoOwner && matchingMessage;
@@ -52,6 +52,12 @@ function getExistingTargetPullRequests(sourceCommit, sourcePullRequest) {
52
52
  number: targetPullRequest.number,
53
53
  branch: targetPullRequest.baseRefName,
54
54
  state: targetPullRequest.state,
55
+ mergeCommit: targetPullRequest.targetMergeCommit
56
+ ? {
57
+ sha: targetPullRequest.targetMergeCommit.oid,
58
+ message: targetPullRequest.targetMergeCommit.message,
59
+ }
60
+ : undefined,
55
61
  };
56
62
  });
57
63
  }
@@ -40,6 +40,10 @@ describe('getExpectedTargetPullRequests', () => {
40
40
  state: 'MERGED',
41
41
  number: 5678,
42
42
  url: 'https://github.com/elastic/kibana/pull/5678',
43
+ mergeCommit: {
44
+ message: 'identical messages (#1234)',
45
+ sha: 'target-merge-commit-sha',
46
+ },
43
47
  },
44
48
  ]);
45
49
  });
@@ -122,6 +126,10 @@ describe('getExpectedTargetPullRequests', () => {
122
126
  state: 'MERGED',
123
127
  number: 5678,
124
128
  url: 'https://github.com/elastic/kibana/pull/5678',
129
+ mergeCommit: {
130
+ message: 'message two (#1234)',
131
+ sha: 'target-merge-commit-sha',
132
+ },
125
133
  },
126
134
  ]);
127
135
  });
@@ -168,6 +176,10 @@ describe('getExpectedTargetPullRequests', () => {
168
176
  state: 'MERGED',
169
177
  number: 5678,
170
178
  url: 'https://github.com/elastic/kibana/pull/5678',
179
+ mergeCommit: {
180
+ message: 'message one (#1234)\n\nsomething else',
181
+ sha: 'target-merge-commit-sha',
182
+ },
171
183
  },
172
184
  ]);
173
185
  });
@@ -218,6 +230,10 @@ describe('getExpectedTargetPullRequests', () => {
218
230
  state: 'MERGED',
219
231
  number: 5678,
220
232
  url: 'https://github.com/elastic/kibana/pull/5678',
233
+ mergeCommit: {
234
+ message: 'identical messages (#1234)',
235
+ sha: 'target-merge-commit-sha',
236
+ },
221
237
  },
222
238
  { branch: '7.1', state: 'MISSING' },
223
239
  ]);
@@ -404,6 +420,10 @@ describe('getExpectedTargetPullRequests', () => {
404
420
  number: 5678,
405
421
  state: 'MERGED',
406
422
  url: 'https://github.com/elastic/kibana/pull/5678',
423
+ mergeCommit: {
424
+ message: 'identical messages (#1234)',
425
+ sha: 'target-merge-commit-sha',
426
+ },
407
427
  },
408
428
  { branch: 'branch-1', state: 'MISSING' },
409
429
  { branch: 'branch-2', state: 'MISSING' },
@@ -1,6 +1,7 @@
1
1
  import { SourceCommitWithTargetPullRequest } from './parseSourceCommit';
2
2
  export declare function getMockSourceCommit({ sourceCommit, sourcePullRequest, timelineItems, }: {
3
3
  sourceCommit: {
4
+ sha?: string;
4
5
  message: string;
5
6
  commitedDate?: string;
6
7
  };
@@ -2,65 +2,91 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getMockSourceCommit = void 0;
4
4
  function getMockSourceCommit({ sourceCommit, sourcePullRequest, timelineItems = [], }) {
5
+ const defaultTargetPullRequestTitle = 'DO NOT USE: Default Pull Request Title';
6
+ const defaultSourceCommitSha = 'DO NOT USE: default-source-commit-sha';
7
+ const baseMockCommit = {
8
+ repository: {
9
+ name: 'kibana',
10
+ owner: { login: 'elastic' },
11
+ },
12
+ committedDate: sourceCommit.commitedDate ?? '2021-12-22T00:00:00Z',
13
+ oid: sourceCommit.sha ?? defaultSourceCommitSha,
14
+ message: sourceCommit.message,
15
+ };
16
+ if (!sourcePullRequest) {
17
+ return {
18
+ ...baseMockCommit,
19
+ associatedPullRequests: {
20
+ edges: null,
21
+ },
22
+ };
23
+ }
5
24
  return {
6
25
  repository: {
7
26
  name: 'kibana',
8
27
  owner: { login: 'elastic' },
9
28
  },
10
29
  committedDate: sourceCommit.commitedDate ?? '2021-12-22T00:00:00Z',
11
- oid: '79cf18453ec32a4677009dcbab1c9c8c73fc14fe',
30
+ oid: sourceCommit.sha ?? defaultSourceCommitSha,
12
31
  message: sourceCommit.message,
13
32
  associatedPullRequests: {
14
- edges: !sourcePullRequest
15
- ? null
16
- : [
17
- {
18
- node: {
19
- url: `https://github.com/elastic/kibana/pull/${sourcePullRequest.number}`,
20
- labels: {
21
- nodes: (sourcePullRequest.labels ?? []).map((name) => ({
22
- name,
23
- })),
24
- },
25
- baseRefName: sourcePullRequest.sourceBranch ??
26
- 'source-branch-from-associated-pull-request',
27
- number: sourcePullRequest.number,
28
- timelineItems: {
29
- edges: timelineItems.map((timelineItem) => {
30
- return {
31
- node: {
32
- targetPullRequest: {
33
- __typename: 'PullRequest',
34
- url: `https://github.com/elastic/kibana/pull/${timelineItem.number}`,
35
- title: timelineItem.title ?? 'Default PR title (#123)',
36
- number: timelineItem.number,
37
- state: timelineItem.state,
38
- baseRefName: timelineItem.targetBranch,
39
- commits: {
40
- edges: timelineItem.commitMessages.map((message) => ({
41
- node: {
42
- targetCommit: {
43
- repository: {
44
- name: timelineItem.repoName ?? 'kibana',
45
- owner: {
46
- login: timelineItem.repoOwner ?? 'elastic',
47
- },
48
- },
49
- committedDate: '2021-12-23T00:00:00Z',
50
- oid: 'abc',
51
- message: message,
52
- },
53
- },
54
- })),
33
+ edges: [
34
+ {
35
+ node: {
36
+ sourceMergeCommit: {
37
+ oid: sourceCommit.sha ?? defaultSourceCommitSha,
38
+ message: sourceCommit.message,
39
+ },
40
+ url: `https://github.com/elastic/kibana/pull/${sourcePullRequest.number}`,
41
+ labels: {
42
+ nodes: (sourcePullRequest.labels ?? []).map((name) => ({
43
+ name,
44
+ })),
45
+ },
46
+ baseRefName: sourcePullRequest.sourceBranch ??
47
+ 'source-branch-from-associated-pull-request',
48
+ number: sourcePullRequest.number,
49
+ timelineItems: {
50
+ edges: timelineItems.map((timelineItem) => {
51
+ return {
52
+ node: {
53
+ targetPullRequest: {
54
+ __typename: 'PullRequest',
55
+ url: `https://github.com/elastic/kibana/pull/${timelineItem.number}`,
56
+ title: timelineItem.title ?? defaultTargetPullRequestTitle,
57
+ number: timelineItem.number,
58
+ state: timelineItem.state,
59
+ baseRefName: timelineItem.targetBranch,
60
+ targetMergeCommit: timelineItem.state === 'MERGED'
61
+ ? {
62
+ message: timelineItem.commitMessages[0],
63
+ oid: 'target-merge-commit-sha',
64
+ }
65
+ : null,
66
+ repository: {
67
+ name: timelineItem.repoName ?? 'kibana',
68
+ owner: {
69
+ login: timelineItem.repoOwner ?? 'elastic',
55
70
  },
56
71
  },
72
+ commits: {
73
+ edges: timelineItem.commitMessages.map((message) => ({
74
+ node: {
75
+ targetCommit: {
76
+ oid: 'abc',
77
+ message: message,
78
+ },
79
+ },
80
+ })),
81
+ },
57
82
  },
58
- };
59
- }),
60
- },
83
+ },
84
+ };
85
+ }),
61
86
  },
62
87
  },
63
- ],
88
+ },
89
+ ],
64
90
  },
65
91
  };
66
92
  }
@@ -9,7 +9,7 @@ export interface Commit {
9
9
  pullUrl?: string;
10
10
  expectedTargetPullRequests: ExpectedTargetPullRequest[];
11
11
  }
12
- export interface PullRequestNode {
12
+ export interface SourcePullRequestNode {
13
13
  baseRefName: string;
14
14
  url: string;
15
15
  number: number;
@@ -18,8 +18,12 @@ export interface PullRequestNode {
18
18
  name: string;
19
19
  }[];
20
20
  };
21
+ sourceMergeCommit: {
22
+ oid: string;
23
+ message: string;
24
+ };
21
25
  timelineItems: {
22
- edges: Array<TimelineEdge>;
26
+ edges: TimelineEdge[];
23
27
  };
24
28
  }
25
29
  export declare type TimelineEdge = TimelinePullRequestEdge | TimelineIssueEdge;
@@ -32,10 +36,23 @@ export interface TimelinePullRequestEdge {
32
36
  state: 'OPEN' | 'CLOSED' | 'MERGED';
33
37
  baseRefName: string;
34
38
  number: number;
39
+ targetMergeCommit: {
40
+ oid: string;
41
+ message: string;
42
+ } | null;
43
+ repository: {
44
+ name: string;
45
+ owner: {
46
+ login: string;
47
+ };
48
+ };
35
49
  commits: {
36
50
  edges: Array<{
37
51
  node: {
38
- targetCommit: InnerCommitNode;
52
+ targetCommit: {
53
+ message: string;
54
+ oid: string;
55
+ };
39
56
  };
40
57
  }>;
41
58
  };
@@ -49,7 +66,7 @@ interface TimelineIssueEdge {
49
66
  };
50
67
  };
51
68
  }
52
- declare type InnerCommitNode = {
69
+ export declare type SourceCommitWithTargetPullRequest = {
53
70
  repository: {
54
71
  name: string;
55
72
  owner: {
@@ -59,11 +76,9 @@ declare type InnerCommitNode = {
59
76
  oid: string;
60
77
  message: string;
61
78
  committedDate: string;
62
- };
63
- export declare type SourceCommitWithTargetPullRequest = InnerCommitNode & {
64
79
  associatedPullRequests: {
65
80
  edges: {
66
- node: PullRequestNode;
81
+ node: SourcePullRequestNode;
67
82
  }[] | null;
68
83
  };
69
84
  };
@@ -76,7 +91,6 @@ export declare function parseSourceCommit({ sourceCommit, options, }: {
76
91
  };
77
92
  }): Commit;
78
93
  export declare const sourceCommitWithTargetPullRequestFragment: {
79
- name: string;
80
94
  source: string;
81
95
  };
82
96
  export {};