release-please 14.1.0 → 14.2.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/CHANGELOG.md +21 -0
- package/build/src/commit.d.ts +2 -1
- package/build/src/commit.js +2 -2
- package/build/src/github.d.ts +28 -3
- package/build/src/github.js +98 -30
- package/build/src/manifest.d.ts +3 -0
- package/build/src/manifest.js +69 -68
- package/build/src/plugin.d.ts +3 -1
- package/build/src/plugin.js +3 -1
- package/build/src/plugins/cargo-workspace.js +9 -10
- package/build/src/plugins/linked-versions.d.ts +2 -0
- package/build/src/plugins/linked-versions.js +5 -6
- package/build/src/plugins/maven-workspace.js +14 -14
- package/build/src/plugins/merge.js +1 -2
- package/build/src/plugins/node-workspace.js +11 -12
- package/build/src/plugins/workspace.d.ts +3 -1
- package/build/src/plugins/workspace.js +20 -20
- package/build/src/strategies/base.d.ts +3 -0
- package/build/src/strategies/base.js +26 -24
- package/build/src/strategies/dotnet-yoshi.js +2 -3
- package/build/src/strategies/go-yoshi.js +7 -8
- package/build/src/strategies/java-yoshi.js +1 -2
- package/build/src/strategies/java.js +9 -8
- package/build/src/strategies/php-yoshi.js +4 -5
- package/build/src/strategies/python.js +2 -3
- package/build/src/strategies/rust.js +8 -9
- package/build/src/update.d.ts +2 -1
- package/build/src/updaters/dart/pubspec-yaml.d.ts +2 -1
- package/build/src/updaters/dart/pubspec-yaml.js +4 -4
- package/build/src/updaters/dotnet/apis.d.ts +2 -1
- package/build/src/updaters/dotnet/apis.js +2 -2
- package/build/src/updaters/elixir/elixir-mix-exs.d.ts +2 -1
- package/build/src/updaters/elixir/elixir-mix-exs.js +2 -2
- package/build/src/updaters/generic-json.d.ts +2 -1
- package/build/src/updaters/generic-json.js +2 -2
- package/build/src/updaters/generic-yaml.d.ts +2 -1
- package/build/src/updaters/generic-yaml.js +3 -3
- package/build/src/updaters/generic.d.ts +2 -1
- package/build/src/updaters/generic.js +2 -2
- package/build/src/updaters/helm/chart-yaml.d.ts +2 -1
- package/build/src/updaters/helm/chart-yaml.js +2 -2
- package/build/src/updaters/java/java-update.d.ts +2 -1
- package/build/src/updaters/java/java-update.js +2 -2
- package/build/src/updaters/java/versions-manifest.d.ts +2 -1
- package/build/src/updaters/java/versions-manifest.js +2 -2
- package/build/src/updaters/krm/krm-blueprint-version.d.ts +2 -1
- package/build/src/updaters/krm/krm-blueprint-version.js +2 -2
- package/build/src/updaters/node/package-json.d.ts +2 -1
- package/build/src/updaters/node/package-json.js +2 -2
- package/build/src/updaters/node/package-lock-json.d.ts +2 -1
- package/build/src/updaters/node/package-lock-json.js +2 -2
- package/build/src/updaters/node/samples-package-json.d.ts +2 -1
- package/build/src/updaters/node/samples-package-json.js +2 -2
- package/build/src/updaters/ocaml/dune-project.d.ts +2 -1
- package/build/src/updaters/ocaml/dune-project.js +2 -2
- package/build/src/updaters/ocaml/esy-json.d.ts +2 -1
- package/build/src/updaters/ocaml/esy-json.js +2 -2
- package/build/src/updaters/ocaml/opam.d.ts +2 -1
- package/build/src/updaters/ocaml/opam.js +2 -2
- package/build/src/updaters/php/php-manifest.d.ts +2 -1
- package/build/src/updaters/php/php-manifest.js +3 -3
- package/build/src/updaters/php/root-composer-update-packages.d.ts +2 -1
- package/build/src/updaters/php/root-composer-update-packages.js +3 -3
- package/build/src/updaters/python/pyproject-toml.d.ts +2 -1
- package/build/src/updaters/python/pyproject-toml.js +2 -2
- package/build/src/updaters/rust/cargo-lock.d.ts +2 -1
- package/build/src/updaters/rust/cargo-lock.js +3 -3
- package/build/src/updaters/rust/cargo-toml.d.ts +2 -1
- package/build/src/updaters/rust/cargo-toml.js +7 -7
- package/build/src/updaters/terraform/module-version.d.ts +2 -1
- package/build/src/updaters/terraform/module-version.js +2 -2
- package/build/src/util/branch-name.d.ts +2 -1
- package/build/src/util/branch-name.js +2 -2
- package/build/src/util/pull-request-body.d.ts +2 -1
- package/build/src/util/pull-request-body.js +9 -9
- package/build/src/util/pull-request-title.d.ts +3 -2
- package/build/src/util/pull-request-title.js +8 -7
- package/build/src/versioning-strategies/default.d.ts +3 -0
- package/build/src/versioning-strategies/default.js +3 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,27 @@
|
|
|
4
4
|
|
|
5
5
|
[1]: https://www.npmjs.com/package/release-please?activeTab=versions
|
|
6
6
|
|
|
7
|
+
## [14.2.0](https://github.com/googleapis/release-please/compare/v14.1.2...v14.2.0) (2022-08-25)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* maintain an instance logger ([#1599](https://github.com/googleapis/release-please/issues/1599)) ([adb8053](https://github.com/googleapis/release-please/commit/adb805357d6344f1737bb3541ec7354e76f45cdc))
|
|
13
|
+
|
|
14
|
+
## [14.1.2](https://github.com/googleapis/release-please/compare/v14.1.1...v14.1.2) (2022-08-25)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* **deps:** update code-suggester to 4.1.0 ([#1600](https://github.com/googleapis/release-please/issues/1600)) ([e123a39](https://github.com/googleapis/release-please/commit/e123a392798e30ce75808f3b74e9b9836832725f))
|
|
20
|
+
|
|
21
|
+
## [14.1.1](https://github.com/googleapis/release-please/compare/v14.1.0...v14.1.1) (2022-08-23)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Bug Fixes
|
|
25
|
+
|
|
26
|
+
* add REST API call to fetch pull requests without files ([#1591](https://github.com/googleapis/release-please/issues/1591)) ([b875a1f](https://github.com/googleapis/release-please/commit/b875a1f437889a46f8cb6e86648073b51401ab9e))
|
|
27
|
+
|
|
7
28
|
## [14.1.0](https://github.com/googleapis/release-please/compare/v14.0.0...v14.1.0) (2022-08-19)
|
|
8
29
|
|
|
9
30
|
|
package/build/src/commit.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { PullRequest } from './pull-request';
|
|
2
|
+
import { Logger } from './util/logger';
|
|
2
3
|
import * as parser from '@conventional-commits/parser';
|
|
3
4
|
export interface Commit {
|
|
4
5
|
sha: string;
|
|
@@ -23,4 +24,4 @@ export interface ConventionalCommit extends Commit {
|
|
|
23
24
|
* more commits returned as a single raw commit may contain multiple release
|
|
24
25
|
* messages.
|
|
25
26
|
*/
|
|
26
|
-
export declare function parseConventionalCommits(commits: Commit[]): ConventionalCommit[];
|
|
27
|
+
export declare function parseConventionalCommits(commits: Commit[], logger?: Logger): ConventionalCommit[];
|
package/build/src/commit.js
CHANGED
|
@@ -292,7 +292,7 @@ function parseCommits(message) {
|
|
|
292
292
|
* more commits returned as a single raw commit may contain multiple release
|
|
293
293
|
* messages.
|
|
294
294
|
*/
|
|
295
|
-
function parseConventionalCommits(commits) {
|
|
295
|
+
function parseConventionalCommits(commits, logger = logger_1.logger) {
|
|
296
296
|
const conventionalCommits = [];
|
|
297
297
|
for (const commit of commits) {
|
|
298
298
|
const commitMessage = preprocessCommitMessage(commit);
|
|
@@ -315,7 +315,7 @@ function parseConventionalCommits(commits) {
|
|
|
315
315
|
}
|
|
316
316
|
}
|
|
317
317
|
catch (_err) {
|
|
318
|
-
|
|
318
|
+
logger.debug(`commit could not be parsed: ${commit.sha} ${commit.message.split('\n')[0]}`);
|
|
319
319
|
}
|
|
320
320
|
}
|
|
321
321
|
return conventionalCommits;
|
package/build/src/github.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { ReleasePullRequest } from './release-pull-request';
|
|
|
10
10
|
import { Update } from './update';
|
|
11
11
|
import { Release } from './release';
|
|
12
12
|
import { GitHubFileContents } from '@google-automations/git-file-utils';
|
|
13
|
+
import { Logger } from 'code-suggester/build/src/types';
|
|
13
14
|
declare type RequestBuilderType = typeof request;
|
|
14
15
|
declare type DefaultFunctionType = RequestBuilderType['defaults'];
|
|
15
16
|
declare type RequestFunctionType = ReturnType<DefaultFunctionType>;
|
|
@@ -21,6 +22,7 @@ export interface OctokitAPIs {
|
|
|
21
22
|
export interface GitHubOptions {
|
|
22
23
|
repository: Repository;
|
|
23
24
|
octokitAPIs: OctokitAPIs;
|
|
25
|
+
logger?: Logger;
|
|
24
26
|
}
|
|
25
27
|
interface GitHubCreateOptions {
|
|
26
28
|
owner: string;
|
|
@@ -71,6 +73,7 @@ export declare class GitHub {
|
|
|
71
73
|
private request;
|
|
72
74
|
private graphql;
|
|
73
75
|
private fileCache;
|
|
76
|
+
private logger;
|
|
74
77
|
private constructor();
|
|
75
78
|
/**
|
|
76
79
|
* Build a new GitHub client with auto-detected default branch.
|
|
@@ -138,12 +141,34 @@ export declare class GitHub {
|
|
|
138
141
|
/**
|
|
139
142
|
* Iterate through merged pull requests with a max number of results scanned.
|
|
140
143
|
*
|
|
141
|
-
* @param {
|
|
142
|
-
*
|
|
144
|
+
* @param {string} targetBranch The base branch of the pull request
|
|
145
|
+
* @param {string} status The status of the pull request
|
|
146
|
+
* @param {number} maxResults Limit the number of results searched. Defaults to
|
|
147
|
+
* unlimited.
|
|
148
|
+
* @param {boolean} includeFiles Whether to fetch the list of files included in
|
|
149
|
+
* the pull request. Defaults to `true`.
|
|
143
150
|
* @yields {PullRequest}
|
|
144
151
|
* @throws {GitHubAPIError} on an API error
|
|
145
152
|
*/
|
|
146
|
-
pullRequestIterator(targetBranch: string, status?: 'OPEN' | 'CLOSED' | 'MERGED', maxResults?: number): AsyncGenerator<PullRequest, void,
|
|
153
|
+
pullRequestIterator(targetBranch: string, status?: 'OPEN' | 'CLOSED' | 'MERGED', maxResults?: number, includeFiles?: boolean): AsyncGenerator<PullRequest, void, void>;
|
|
154
|
+
/**
|
|
155
|
+
* Helper implementation of pullRequestIterator that includes files via
|
|
156
|
+
* the graphQL API.
|
|
157
|
+
*
|
|
158
|
+
* @param {string} targetBranch The base branch of the pull request
|
|
159
|
+
* @param {string} status The status of the pull request
|
|
160
|
+
* @param {number} maxResults Limit the number of results searched
|
|
161
|
+
*/
|
|
162
|
+
private pullRequestIteratorWithFiles;
|
|
163
|
+
/**
|
|
164
|
+
* Helper implementation of pullRequestIterator that excludes files
|
|
165
|
+
* via the REST API.
|
|
166
|
+
*
|
|
167
|
+
* @param {string} targetBranch The base branch of the pull request
|
|
168
|
+
* @param {string} status The status of the pull request
|
|
169
|
+
* @param {number} maxResults Limit the number of results searched
|
|
170
|
+
*/
|
|
171
|
+
private pullRequestIteratorWithoutFiles;
|
|
147
172
|
/**
|
|
148
173
|
* Return a list of merged pull requests. The list is not guaranteed to be sorted
|
|
149
174
|
* by merged_at, but is generally most recent first.
|
package/build/src/github.js
CHANGED
|
@@ -30,6 +30,7 @@ const signoff_commit_message_1 = require("./util/signoff-commit-message");
|
|
|
30
30
|
const git_file_utils_1 = require("@google-automations/git-file-utils");
|
|
31
31
|
class GitHub {
|
|
32
32
|
constructor(options) {
|
|
33
|
+
var _a;
|
|
33
34
|
/**
|
|
34
35
|
* Get the list of file paths modified in a given commit.
|
|
35
36
|
*
|
|
@@ -38,7 +39,7 @@ class GitHub {
|
|
|
38
39
|
* @throws {GitHubAPIError} on an API error
|
|
39
40
|
*/
|
|
40
41
|
this.getCommitFiles = wrapAsync(async (sha) => {
|
|
41
|
-
|
|
42
|
+
this.logger.debug(`Backfilling file list for commit: ${sha}`);
|
|
42
43
|
const files = [];
|
|
43
44
|
for await (const resp of this.octokit.paginate.iterator(this.octokit.repos.getCommit, {
|
|
44
45
|
owner: this.repository.owner,
|
|
@@ -52,10 +53,10 @@ class GitHub {
|
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
if (files.length >= 3000) {
|
|
55
|
-
|
|
56
|
+
this.logger.warn(`Found ${files.length} files. This may not include all the files.`);
|
|
56
57
|
}
|
|
57
58
|
else {
|
|
58
|
-
|
|
59
|
+
this.logger.debug(`Found ${files.length} files`);
|
|
59
60
|
}
|
|
60
61
|
return files;
|
|
61
62
|
});
|
|
@@ -69,26 +70,26 @@ class GitHub {
|
|
|
69
70
|
if (response) {
|
|
70
71
|
return response;
|
|
71
72
|
}
|
|
72
|
-
|
|
73
|
+
this.logger.trace('no GraphQL response, retrying');
|
|
73
74
|
}
|
|
74
75
|
catch (err) {
|
|
75
76
|
if (err.status !== 502) {
|
|
76
77
|
throw err;
|
|
77
78
|
}
|
|
78
79
|
if (maxRetries === 0) {
|
|
79
|
-
|
|
80
|
+
this.logger.warn('ran out of retries and response is required');
|
|
80
81
|
throw err;
|
|
81
82
|
}
|
|
82
|
-
|
|
83
|
+
this.logger.info(`received 502 error, ${maxRetries} attempts remaining`);
|
|
83
84
|
}
|
|
84
85
|
maxRetries -= 1;
|
|
85
86
|
if (maxRetries >= 0) {
|
|
86
|
-
|
|
87
|
+
this.logger.trace(`sleeping ${seconds} seconds`);
|
|
87
88
|
await (0, exports.sleepInMs)(1000 * seconds);
|
|
88
89
|
seconds = Math.min(seconds * 2, MAX_SLEEP_SECONDS);
|
|
89
90
|
}
|
|
90
91
|
}
|
|
91
|
-
|
|
92
|
+
this.logger.trace('ran out of retries');
|
|
92
93
|
return undefined;
|
|
93
94
|
});
|
|
94
95
|
/**
|
|
@@ -106,7 +107,7 @@ class GitHub {
|
|
|
106
107
|
if (prefix) {
|
|
107
108
|
prefix = normalizePrefix(prefix);
|
|
108
109
|
}
|
|
109
|
-
|
|
110
|
+
this.logger.debug(`finding files by filename: ${filename}, ref: ${ref}, prefix: ${prefix}`);
|
|
110
111
|
return await this.fileCache.findFilesByFilename(filename, ref, prefix);
|
|
111
112
|
});
|
|
112
113
|
this.createPullRequest = wrapAsync(async (pullRequest, targetBranch, message, updates, options) => {
|
|
@@ -122,7 +123,7 @@ class GitHub {
|
|
|
122
123
|
force: true,
|
|
123
124
|
fork: !!(options === null || options === void 0 ? void 0 : options.fork),
|
|
124
125
|
message,
|
|
125
|
-
logger:
|
|
126
|
+
logger: this.logger,
|
|
126
127
|
draft: !!(options === null || options === void 0 ? void 0 : options.draft),
|
|
127
128
|
labels: pullRequest.labels,
|
|
128
129
|
});
|
|
@@ -178,11 +179,11 @@ class GitHub {
|
|
|
178
179
|
force: true,
|
|
179
180
|
fork: (options === null || options === void 0 ? void 0 : options.fork) === false ? false : true,
|
|
180
181
|
message,
|
|
181
|
-
logger:
|
|
182
|
+
logger: this.logger,
|
|
182
183
|
draft: releasePullRequest.draft,
|
|
183
184
|
});
|
|
184
185
|
if (prNumber !== number) {
|
|
185
|
-
|
|
186
|
+
this.logger.warn(`updated code for ${prNumber}, but update requested for ${number}`);
|
|
186
187
|
}
|
|
187
188
|
const response = await this.octokit.pulls.update({
|
|
188
189
|
owner: this.repository.owner,
|
|
@@ -273,7 +274,7 @@ class GitHub {
|
|
|
273
274
|
* @throws {GitHubAPIError} on an API error
|
|
274
275
|
*/
|
|
275
276
|
this.commentOnIssue = wrapAsync(async (comment, number) => {
|
|
276
|
-
|
|
277
|
+
this.logger.debug(`adding comment to https://github.com/${this.repository.owner}/${this.repository.repo}/issue/${number}`);
|
|
277
278
|
const resp = await this.octokit.issues.createComment({
|
|
278
279
|
owner: this.repository.owner,
|
|
279
280
|
repo: this.repository.repo,
|
|
@@ -292,7 +293,7 @@ class GitHub {
|
|
|
292
293
|
if (labels.length === 0) {
|
|
293
294
|
return;
|
|
294
295
|
}
|
|
295
|
-
|
|
296
|
+
this.logger.debug(`removing labels: ${labels} from issue/pull ${number}`);
|
|
296
297
|
await Promise.all(labels.map(label => this.octokit.issues.removeLabel({
|
|
297
298
|
owner: this.repository.owner,
|
|
298
299
|
repo: this.repository.repo,
|
|
@@ -310,7 +311,7 @@ class GitHub {
|
|
|
310
311
|
if (labels.length === 0) {
|
|
311
312
|
return;
|
|
312
313
|
}
|
|
313
|
-
|
|
314
|
+
this.logger.debug(`adding labels: ${labels} from issue/pull ${number}`);
|
|
314
315
|
await this.octokit.issues.addLabels({
|
|
315
316
|
owner: this.repository.owner,
|
|
316
317
|
repo: this.repository.repo,
|
|
@@ -323,6 +324,7 @@ class GitHub {
|
|
|
323
324
|
this.request = options.octokitAPIs.request;
|
|
324
325
|
this.graphql = options.octokitAPIs.graphql;
|
|
325
326
|
this.fileCache = new git_file_utils_1.RepositoryFileCache(this.octokit, this.repository);
|
|
327
|
+
this.logger = (_a = options.logger) !== null && _a !== void 0 ? _a : logger_1.logger;
|
|
326
328
|
}
|
|
327
329
|
/**
|
|
328
330
|
* Build a new GitHub client with auto-detected default branch.
|
|
@@ -450,7 +452,7 @@ class GitHub {
|
|
|
450
452
|
}
|
|
451
453
|
async mergeCommitsGraphQL(targetBranch, cursor, options = {}) {
|
|
452
454
|
var _a, _b;
|
|
453
|
-
|
|
455
|
+
this.logger.debug(`Fetching merge commits on branch ${targetBranch} with cursor: ${cursor}`);
|
|
454
456
|
const query = `query pullRequestsSince($owner: String!, $repo: String!, $num: Int!, $maxFilesChanged: Int, $targetBranch: String!, $cursor: String) {
|
|
455
457
|
repository(owner: $owner, name: $repo) {
|
|
456
458
|
ref(qualifiedName: $targetBranch) {
|
|
@@ -510,12 +512,12 @@ class GitHub {
|
|
|
510
512
|
...params,
|
|
511
513
|
});
|
|
512
514
|
if (!response) {
|
|
513
|
-
|
|
515
|
+
this.logger.warn(`Did not receive a response for query: ${query}`, params);
|
|
514
516
|
return null;
|
|
515
517
|
}
|
|
516
518
|
// if the branch does exist, return null
|
|
517
519
|
if (!((_a = response.repository) === null || _a === void 0 ? void 0 : _a.ref)) {
|
|
518
|
-
|
|
520
|
+
this.logger.warn(`Could not find commits for branch ${targetBranch} - it likely does not exist.`);
|
|
519
521
|
return null;
|
|
520
522
|
}
|
|
521
523
|
const history = response.repository.ref.target.history;
|
|
@@ -542,7 +544,7 @@ class GitHub {
|
|
|
542
544
|
files,
|
|
543
545
|
};
|
|
544
546
|
if (((_b = pullRequest.files.pageInfo) === null || _b === void 0 ? void 0 : _b.hasNextPage) && options.backfillFiles) {
|
|
545
|
-
|
|
547
|
+
this.logger.info(`PR #${pullRequest.number} has many files, backfilling`);
|
|
546
548
|
commit.files = await this.getCommitFiles(graphCommit.sha);
|
|
547
549
|
}
|
|
548
550
|
else {
|
|
@@ -568,12 +570,32 @@ class GitHub {
|
|
|
568
570
|
/**
|
|
569
571
|
* Iterate through merged pull requests with a max number of results scanned.
|
|
570
572
|
*
|
|
571
|
-
* @param {
|
|
572
|
-
*
|
|
573
|
+
* @param {string} targetBranch The base branch of the pull request
|
|
574
|
+
* @param {string} status The status of the pull request
|
|
575
|
+
* @param {number} maxResults Limit the number of results searched. Defaults to
|
|
576
|
+
* unlimited.
|
|
577
|
+
* @param {boolean} includeFiles Whether to fetch the list of files included in
|
|
578
|
+
* the pull request. Defaults to `true`.
|
|
573
579
|
* @yields {PullRequest}
|
|
574
580
|
* @throws {GitHubAPIError} on an API error
|
|
575
581
|
*/
|
|
576
|
-
async *pullRequestIterator(targetBranch, status = 'MERGED', maxResults = Number.MAX_SAFE_INTEGER) {
|
|
582
|
+
async *pullRequestIterator(targetBranch, status = 'MERGED', maxResults = Number.MAX_SAFE_INTEGER, includeFiles = true) {
|
|
583
|
+
const generator = includeFiles
|
|
584
|
+
? this.pullRequestIteratorWithFiles(targetBranch, status, maxResults)
|
|
585
|
+
: this.pullRequestIteratorWithoutFiles(targetBranch, status, maxResults);
|
|
586
|
+
for await (const pullRequest of generator) {
|
|
587
|
+
yield pullRequest;
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
/**
|
|
591
|
+
* Helper implementation of pullRequestIterator that includes files via
|
|
592
|
+
* the graphQL API.
|
|
593
|
+
*
|
|
594
|
+
* @param {string} targetBranch The base branch of the pull request
|
|
595
|
+
* @param {string} status The status of the pull request
|
|
596
|
+
* @param {number} maxResults Limit the number of results searched
|
|
597
|
+
*/
|
|
598
|
+
async *pullRequestIteratorWithFiles(targetBranch, status = 'MERGED', maxResults = Number.MAX_SAFE_INTEGER) {
|
|
577
599
|
let cursor = undefined;
|
|
578
600
|
let results = 0;
|
|
579
601
|
while (results < maxResults) {
|
|
@@ -592,6 +614,52 @@ class GitHub {
|
|
|
592
614
|
cursor = response.pageInfo.endCursor;
|
|
593
615
|
}
|
|
594
616
|
}
|
|
617
|
+
/**
|
|
618
|
+
* Helper implementation of pullRequestIterator that excludes files
|
|
619
|
+
* via the REST API.
|
|
620
|
+
*
|
|
621
|
+
* @param {string} targetBranch The base branch of the pull request
|
|
622
|
+
* @param {string} status The status of the pull request
|
|
623
|
+
* @param {number} maxResults Limit the number of results searched
|
|
624
|
+
*/
|
|
625
|
+
async *pullRequestIteratorWithoutFiles(targetBranch, status = 'MERGED', maxResults = Number.MAX_SAFE_INTEGER) {
|
|
626
|
+
const statusMap = {
|
|
627
|
+
OPEN: 'open',
|
|
628
|
+
CLOSED: 'closed',
|
|
629
|
+
MERGED: 'closed',
|
|
630
|
+
};
|
|
631
|
+
let results = 0;
|
|
632
|
+
for await (const { data: pulls } of this.octokit.paginate.iterator(this.octokit.rest.pulls.list, {
|
|
633
|
+
state: statusMap[status],
|
|
634
|
+
owner: this.repository.owner,
|
|
635
|
+
repo: this.repository.repo,
|
|
636
|
+
base: targetBranch,
|
|
637
|
+
})) {
|
|
638
|
+
for (const pull of pulls) {
|
|
639
|
+
// The REST API does not have an option for "merged"
|
|
640
|
+
// pull requests - they are closed with a `merge_commit_sha`
|
|
641
|
+
if (status !== 'MERGED' || pull.merge_commit_sha) {
|
|
642
|
+
results += 1;
|
|
643
|
+
yield {
|
|
644
|
+
headBranchName: pull.head.ref,
|
|
645
|
+
baseBranchName: pull.base.ref,
|
|
646
|
+
number: pull.number,
|
|
647
|
+
title: pull.title,
|
|
648
|
+
body: pull.body || '',
|
|
649
|
+
labels: pull.labels.map(label => label.name),
|
|
650
|
+
files: [],
|
|
651
|
+
sha: pull.merge_commit_sha || undefined,
|
|
652
|
+
};
|
|
653
|
+
if (results >= maxResults) {
|
|
654
|
+
break;
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
if (results >= maxResults) {
|
|
659
|
+
break;
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
}
|
|
595
663
|
/**
|
|
596
664
|
* Return a list of merged pull requests. The list is not guaranteed to be sorted
|
|
597
665
|
* by merged_at, but is generally most recent first.
|
|
@@ -605,7 +673,7 @@ class GitHub {
|
|
|
605
673
|
*/
|
|
606
674
|
async pullRequestsGraphQL(targetBranch, states = 'MERGED', cursor) {
|
|
607
675
|
var _a;
|
|
608
|
-
|
|
676
|
+
this.logger.debug(`Fetching ${states} pull requests on branch ${targetBranch} with cursor ${cursor}`);
|
|
609
677
|
const response = await this.graphqlRequest({
|
|
610
678
|
query: `query mergedPullRequests($owner: String!, $repo: String!, $num: Int!, $maxFilesChanged: Int, $targetBranch: String!, $states: [PullRequestState!], $cursor: String) {
|
|
611
679
|
repository(owner: $owner, name: $repo) {
|
|
@@ -650,7 +718,7 @@ class GitHub {
|
|
|
650
718
|
maxFilesChanged: 64,
|
|
651
719
|
});
|
|
652
720
|
if (!((_a = response === null || response === void 0 ? void 0 : response.repository) === null || _a === void 0 ? void 0 : _a.pullRequests)) {
|
|
653
|
-
|
|
721
|
+
this.logger.warn(`Could not find merged pull requests for branch ${targetBranch} - it likely does not exist.`);
|
|
654
722
|
return null;
|
|
655
723
|
}
|
|
656
724
|
const pullRequests = (response.repository.pullRequests.nodes ||
|
|
@@ -704,7 +772,7 @@ class GitHub {
|
|
|
704
772
|
}
|
|
705
773
|
}
|
|
706
774
|
async releaseGraphQL(cursor) {
|
|
707
|
-
|
|
775
|
+
this.logger.debug(`Fetching releases with cursor ${cursor}`);
|
|
708
776
|
const response = await this.graphqlRequest({
|
|
709
777
|
query: `query releases($owner: String!, $repo: String!, $num: Int!, $cursor: String) {
|
|
710
778
|
repository(owner: $owner, name: $repo) {
|
|
@@ -734,7 +802,7 @@ class GitHub {
|
|
|
734
802
|
num: 25,
|
|
735
803
|
});
|
|
736
804
|
if (!response.repository.releases.nodes.length) {
|
|
737
|
-
|
|
805
|
+
this.logger.warn('Could not find releases.');
|
|
738
806
|
return null;
|
|
739
807
|
}
|
|
740
808
|
const releases = response.repository.releases.nodes;
|
|
@@ -744,7 +812,7 @@ class GitHub {
|
|
|
744
812
|
.filter(release => !!release.tagCommit)
|
|
745
813
|
.map(release => {
|
|
746
814
|
if (!release.tag || !release.tagCommit) {
|
|
747
|
-
|
|
815
|
+
this.logger.debug(release);
|
|
748
816
|
}
|
|
749
817
|
return {
|
|
750
818
|
name: release.name || undefined,
|
|
@@ -805,7 +873,7 @@ class GitHub {
|
|
|
805
873
|
* @throws {GitHubAPIError} on other API errors
|
|
806
874
|
*/
|
|
807
875
|
async getFileContentsOnBranch(path, branch) {
|
|
808
|
-
|
|
876
|
+
this.logger.debug(`Fetching ${path} from branch ${branch}`);
|
|
809
877
|
try {
|
|
810
878
|
return await this.fileCache.getFileContents(path, branch);
|
|
811
879
|
}
|
|
@@ -884,14 +952,14 @@ class GitHub {
|
|
|
884
952
|
// if the file is missing and create = false, just continue
|
|
885
953
|
// to the next update, otherwise create the file.
|
|
886
954
|
if (!update.createIfMissing) {
|
|
887
|
-
|
|
955
|
+
this.logger.warn(`file ${update.path} did not exist`);
|
|
888
956
|
continue;
|
|
889
957
|
}
|
|
890
958
|
}
|
|
891
959
|
const contentText = content
|
|
892
960
|
? Buffer.from(content.content, 'base64').toString('utf8')
|
|
893
961
|
: undefined;
|
|
894
|
-
const updatedContent = update.updater.updateContent(contentText);
|
|
962
|
+
const updatedContent = update.updater.updateContent(contentText, this.logger);
|
|
895
963
|
if (updatedContent) {
|
|
896
964
|
changes.set(update.path, {
|
|
897
965
|
content: updatedContent,
|
package/build/src/manifest.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { ChangelogSection } from './changelog-notes';
|
|
|
2
2
|
import { GitHub, GitHubRelease } from './github';
|
|
3
3
|
import { Version } from './version';
|
|
4
4
|
import { PullRequest } from './pull-request';
|
|
5
|
+
import { Logger } from './util/logger';
|
|
5
6
|
import { ReleasePullRequest } from './release-pull-request';
|
|
6
7
|
import { ReleaseType, VersioningStrategyType, ChangelogNotesType } from './factory';
|
|
7
8
|
import { Release } from './release';
|
|
@@ -114,6 +115,7 @@ export interface ManifestOptions {
|
|
|
114
115
|
groupPullRequestTitlePattern?: string;
|
|
115
116
|
releaseSearchDepth?: number;
|
|
116
117
|
commitSearchDepth?: number;
|
|
118
|
+
logger?: Logger;
|
|
117
119
|
}
|
|
118
120
|
export interface ReleaserPackageConfig extends ReleaserConfigJson {
|
|
119
121
|
'package-name'?: string;
|
|
@@ -192,6 +194,7 @@ export declare class Manifest {
|
|
|
192
194
|
private groupPullRequestTitlePattern?;
|
|
193
195
|
readonly releaseSearchDepth: number;
|
|
194
196
|
readonly commitSearchDepth: number;
|
|
197
|
+
readonly logger: Logger;
|
|
195
198
|
/**
|
|
196
199
|
* Create a Manifest from explicit config in code. This assumes that the
|
|
197
200
|
* repository has a single component at the root path.
|