release-please 14.1.0 → 14.1.1

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 CHANGED
@@ -4,6 +4,13 @@
4
4
 
5
5
  [1]: https://www.npmjs.com/package/release-please?activeTab=versions
6
6
 
7
+ ## [14.1.1](https://github.com/googleapis/release-please/compare/v14.1.0...v14.1.1) (2022-08-23)
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * 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))
13
+
7
14
  ## [14.1.0](https://github.com/googleapis/release-please/compare/v14.0.0...v14.1.0) (2022-08-19)
8
15
 
9
16
 
@@ -138,12 +138,34 @@ export declare class GitHub {
138
138
  /**
139
139
  * Iterate through merged pull requests with a max number of results scanned.
140
140
  *
141
- * @param {number} maxResults maxResults - Limit the number of results searched.
142
- * Defaults to unlimited.
141
+ * @param {string} targetBranch The base branch of the pull request
142
+ * @param {string} status The status of the pull request
143
+ * @param {number} maxResults Limit the number of results searched. Defaults to
144
+ * unlimited.
145
+ * @param {boolean} includeFiles Whether to fetch the list of files included in
146
+ * the pull request. Defaults to `true`.
143
147
  * @yields {PullRequest}
144
148
  * @throws {GitHubAPIError} on an API error
145
149
  */
146
- pullRequestIterator(targetBranch: string, status?: 'OPEN' | 'CLOSED' | 'MERGED', maxResults?: number): AsyncGenerator<PullRequest, void, unknown>;
150
+ pullRequestIterator(targetBranch: string, status?: 'OPEN' | 'CLOSED' | 'MERGED', maxResults?: number, includeFiles?: boolean): AsyncGenerator<PullRequest, void, void>;
151
+ /**
152
+ * Helper implementation of pullRequestIterator that includes files via
153
+ * the graphQL API.
154
+ *
155
+ * @param {string} targetBranch The base branch of the pull request
156
+ * @param {string} status The status of the pull request
157
+ * @param {number} maxResults Limit the number of results searched
158
+ */
159
+ private pullRequestIteratorWithFiles;
160
+ /**
161
+ * Helper implementation of pullRequestIterator that excludes files
162
+ * via the REST API.
163
+ *
164
+ * @param {string} targetBranch The base branch of the pull request
165
+ * @param {string} status The status of the pull request
166
+ * @param {number} maxResults Limit the number of results searched
167
+ */
168
+ private pullRequestIteratorWithoutFiles;
147
169
  /**
148
170
  * Return a list of merged pull requests. The list is not guaranteed to be sorted
149
171
  * by merged_at, but is generally most recent first.
@@ -568,12 +568,32 @@ class GitHub {
568
568
  /**
569
569
  * Iterate through merged pull requests with a max number of results scanned.
570
570
  *
571
- * @param {number} maxResults maxResults - Limit the number of results searched.
572
- * Defaults to unlimited.
571
+ * @param {string} targetBranch The base branch of the pull request
572
+ * @param {string} status The status of the pull request
573
+ * @param {number} maxResults Limit the number of results searched. Defaults to
574
+ * unlimited.
575
+ * @param {boolean} includeFiles Whether to fetch the list of files included in
576
+ * the pull request. Defaults to `true`.
573
577
  * @yields {PullRequest}
574
578
  * @throws {GitHubAPIError} on an API error
575
579
  */
576
- async *pullRequestIterator(targetBranch, status = 'MERGED', maxResults = Number.MAX_SAFE_INTEGER) {
580
+ async *pullRequestIterator(targetBranch, status = 'MERGED', maxResults = Number.MAX_SAFE_INTEGER, includeFiles = true) {
581
+ const generator = includeFiles
582
+ ? this.pullRequestIteratorWithFiles(targetBranch, status, maxResults)
583
+ : this.pullRequestIteratorWithoutFiles(targetBranch, status, maxResults);
584
+ for await (const pullRequest of generator) {
585
+ yield pullRequest;
586
+ }
587
+ }
588
+ /**
589
+ * Helper implementation of pullRequestIterator that includes files via
590
+ * the graphQL API.
591
+ *
592
+ * @param {string} targetBranch The base branch of the pull request
593
+ * @param {string} status The status of the pull request
594
+ * @param {number} maxResults Limit the number of results searched
595
+ */
596
+ async *pullRequestIteratorWithFiles(targetBranch, status = 'MERGED', maxResults = Number.MAX_SAFE_INTEGER) {
577
597
  let cursor = undefined;
578
598
  let results = 0;
579
599
  while (results < maxResults) {
@@ -592,6 +612,52 @@ class GitHub {
592
612
  cursor = response.pageInfo.endCursor;
593
613
  }
594
614
  }
615
+ /**
616
+ * Helper implementation of pullRequestIterator that excludes files
617
+ * via the REST API.
618
+ *
619
+ * @param {string} targetBranch The base branch of the pull request
620
+ * @param {string} status The status of the pull request
621
+ * @param {number} maxResults Limit the number of results searched
622
+ */
623
+ async *pullRequestIteratorWithoutFiles(targetBranch, status = 'MERGED', maxResults = Number.MAX_SAFE_INTEGER) {
624
+ const statusMap = {
625
+ OPEN: 'open',
626
+ CLOSED: 'closed',
627
+ MERGED: 'closed',
628
+ };
629
+ let results = 0;
630
+ for await (const { data: pulls } of this.octokit.paginate.iterator(this.octokit.rest.pulls.list, {
631
+ state: statusMap[status],
632
+ owner: this.repository.owner,
633
+ repo: this.repository.repo,
634
+ base: targetBranch,
635
+ })) {
636
+ for (const pull of pulls) {
637
+ // The REST API does not have an option for "merged"
638
+ // pull requests - they are closed with a `merge_commit_sha`
639
+ if (status !== 'MERGED' || pull.merge_commit_sha) {
640
+ results += 1;
641
+ yield {
642
+ headBranchName: pull.head.ref,
643
+ baseBranchName: pull.base.ref,
644
+ number: pull.number,
645
+ title: pull.title,
646
+ body: pull.body || '',
647
+ labels: pull.labels.map(label => label.name),
648
+ files: [],
649
+ sha: pull.merge_commit_sha || undefined,
650
+ };
651
+ if (results >= maxResults) {
652
+ break;
653
+ }
654
+ }
655
+ }
656
+ if (results >= maxResults) {
657
+ break;
658
+ }
659
+ }
660
+ }
595
661
  /**
596
662
  * Return a list of merged pull requests. The list is not guaranteed to be sorted
597
663
  * by merged_at, but is generally most recent first.
@@ -444,7 +444,7 @@ class Manifest {
444
444
  async findOpenReleasePullRequests() {
445
445
  logger_1.logger.info('Looking for open release pull requests');
446
446
  const openPullRequests = [];
447
- const generator = this.github.pullRequestIterator(this.targetBranch, 'OPEN');
447
+ const generator = this.github.pullRequestIterator(this.targetBranch, 'OPEN', Number.MAX_SAFE_INTEGER, false);
448
448
  for await (const openPullRequest of generator) {
449
449
  if ((hasAllLabels(this.labels, openPullRequest.labels) ||
450
450
  hasAllLabels(this.snapshotLabels, openPullRequest.labels)) &&
@@ -459,7 +459,7 @@ class Manifest {
459
459
  async findSnoozedReleasePullRequests() {
460
460
  logger_1.logger.info('Looking for snoozed release pull requests');
461
461
  const snoozedPullRequests = [];
462
- const closedGenerator = this.github.pullRequestIterator(this.targetBranch, 'CLOSED');
462
+ const closedGenerator = this.github.pullRequestIterator(this.targetBranch, 'CLOSED', 200, false);
463
463
  for await (const closedPullRequest of closedGenerator) {
464
464
  if (hasAllLabels([exports.SNOOZE_LABEL], closedPullRequest.labels) &&
465
465
  branch_name_1.BranchName.parse(closedPullRequest.headBranchName) &&
@@ -518,7 +518,7 @@ class Manifest {
518
518
  }
519
519
  async *findMergedReleasePullRequests() {
520
520
  // Find merged release pull requests
521
- const pullRequestGenerator = this.github.pullRequestIterator(this.targetBranch, 'MERGED', 200);
521
+ const pullRequestGenerator = this.github.pullRequestIterator(this.targetBranch, 'MERGED', 200, false);
522
522
  for await (const pullRequest of pullRequestGenerator) {
523
523
  if (!hasAllLabels(this.labels, pullRequest.labels)) {
524
524
  continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "release-please",
3
- "version": "14.1.0",
3
+ "version": "14.1.1",
4
4
  "description": "generate release PRs based on the conventionalcommits.org spec",
5
5
  "main": "./build/src/index.js",
6
6
  "bin": "./build/src/bin/release-please.js",