release-please 16.3.0 → 16.4.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.
@@ -6,6 +6,7 @@ export interface VersioningStrategyFactoryOptions {
6
6
  bumpMinorPreMajor?: boolean;
7
7
  bumpPatchForMinorPreMajor?: boolean;
8
8
  prereleaseType?: string;
9
+ prerelease?: boolean;
9
10
  github: GitHub;
10
11
  }
11
12
  export type VersioningStrategyBuilder = (options: VersioningStrategyFactoryOptions) => VersioningStrategy;
@@ -110,6 +110,7 @@ async function buildStrategy(options) {
110
110
  bumpMinorPreMajor: options.bumpMinorPreMajor,
111
111
  bumpPatchForMinorPreMajor: options.bumpPatchForMinorPreMajor,
112
112
  prereleaseType: options.prereleaseType,
113
+ prerelease: options.prerelease,
113
114
  });
114
115
  const changelogNotes = (0, changelog_notes_factory_1.buildChangelogNotes)({
115
116
  type: options.changelogType || 'default',
@@ -508,7 +508,8 @@ class GitHub {
508
508
  }
509
509
  }
510
510
  async mergeCommitsGraphQL(targetBranch, cursor, options = {}) {
511
- var _a, _b, _c, _d;
511
+ var _a, _b, _c, _d, _e, _f, _g;
512
+ var _h;
512
513
  this.logger.debug(`Fetching merge commits on branch ${targetBranch} with cursor: ${cursor}`);
513
514
  const query = `query pullRequestsSince($owner: String!, $repo: String!, $num: Int!, $maxFilesChanged: Int, $targetBranch: String!, $cursor: String) {
514
515
  repository(owner: $owner, name: $repo) {
@@ -579,17 +580,38 @@ class GitHub {
579
580
  }
580
581
  const history = response.repository.ref.target.history;
581
582
  const commits = (history.nodes || []);
583
+ // Count the number of pull requests associated with each merge commit. This is
584
+ // used in the next step to make sure we only find pull requests with a
585
+ // merge commit that contain 1 merged commit.
586
+ const mergeCommitCount = {};
587
+ for (const commit of commits) {
588
+ for (const pr of commit.associatedPullRequests.nodes) {
589
+ if ((_b = pr.mergeCommit) === null || _b === void 0 ? void 0 : _b.oid) {
590
+ (_c = mergeCommitCount[_h = pr.mergeCommit.oid]) !== null && _c !== void 0 ? _c : (mergeCommitCount[_h] = 0);
591
+ mergeCommitCount[pr.mergeCommit.oid]++;
592
+ }
593
+ }
594
+ }
582
595
  const commitData = [];
583
596
  for (const graphCommit of commits) {
584
597
  const commit = {
585
598
  sha: graphCommit.sha,
586
599
  message: graphCommit.message,
587
600
  };
588
- const pullRequest = graphCommit.associatedPullRequests.nodes.find(pr => {
589
- return pr.mergeCommit && pr.mergeCommit.oid === graphCommit.sha;
601
+ const mergePullRequest = graphCommit.associatedPullRequests.nodes.find(pr => {
602
+ return (
603
+ // Only match the pull request with a merge commit if there is a
604
+ // single merged commit in the PR. This means merge commits and squash
605
+ // merges will be matched, but rebase merged PRs will only be matched
606
+ // if they contain a single commit. This is so PRs that are rebased
607
+ // and merged will have ßSfiles backfilled from each commit instead of
608
+ // the whole PR.
609
+ pr.mergeCommit &&
610
+ pr.mergeCommit.oid === graphCommit.sha &&
611
+ mergeCommitCount[pr.mergeCommit.oid] === 1);
590
612
  });
613
+ const pullRequest = mergePullRequest || graphCommit.associatedPullRequests.nodes[0];
591
614
  if (pullRequest) {
592
- const files = (((_b = pullRequest.files) === null || _b === void 0 ? void 0 : _b.nodes) || []).map(node => node.path);
593
615
  commit.pullRequest = {
594
616
  sha: commit.sha,
595
617
  number: pullRequest.number,
@@ -598,16 +620,19 @@ class GitHub {
598
620
  title: pullRequest.title,
599
621
  body: pullRequest.body,
600
622
  labels: pullRequest.labels.nodes.map(node => node.name),
601
- files,
623
+ files: (((_d = pullRequest.files) === null || _d === void 0 ? void 0 : _d.nodes) || []).map(node => node.path),
602
624
  };
603
- if (((_d = (_c = pullRequest.files) === null || _c === void 0 ? void 0 : _c.pageInfo) === null || _d === void 0 ? void 0 : _d.hasNextPage) && options.backfillFiles) {
604
- this.logger.info(`PR #${pullRequest.number} has many files, backfilling`);
625
+ }
626
+ if (mergePullRequest) {
627
+ if (((_f = (_e = mergePullRequest.files) === null || _e === void 0 ? void 0 : _e.pageInfo) === null || _f === void 0 ? void 0 : _f.hasNextPage) &&
628
+ options.backfillFiles) {
629
+ this.logger.info(`PR #${mergePullRequest.number} has many files, backfilling`);
605
630
  commit.files = await this.getCommitFiles(graphCommit.sha);
606
631
  }
607
632
  else {
608
633
  // We cannot directly fetch files on commits via graphql, only provide file
609
634
  // information for commits with associated pull requests
610
- commit.files = files;
635
+ commit.files = (((_g = mergePullRequest.files) === null || _g === void 0 ? void 0 : _g.nodes) || []).map(node => node.path);
611
636
  }
612
637
  }
613
638
  else if (options.backfillFiles) {
@@ -1,5 +1,7 @@
1
1
  export * as Errors from './errors';
2
- export { Manifest, ReleaserConfig, ManifestOptions, PluginType, } from './manifest';
2
+ export { Manifest, ReleaserConfig, ManifestOptions, PluginType, CandidateRelease, CreatedRelease, } from './manifest';
3
+ export { ReleasePullRequest } from './release-pull-request';
4
+ export { PullRequest } from './pull-request';
3
5
  export { Commit, ConventionalCommit } from './commit';
4
6
  export { Strategy } from './strategy';
5
7
  export { BaseStrategyOptions, BuildUpdatesOptions } from './strategies/base';
@@ -189,7 +189,7 @@ export declare const DEFAULT_RELEASE_LABELS: string[];
189
189
  export declare const DEFAULT_SNAPSHOT_LABELS: string[];
190
190
  export declare const SNOOZE_LABEL = "autorelease: snooze";
191
191
  export declare const MANIFEST_PULL_REQUEST_TITLE_PATTERN = "chore: release ${branch}";
192
- interface CreatedRelease extends GitHubRelease {
192
+ export interface CreatedRelease extends GitHubRelease {
193
193
  id: number;
194
194
  path: string;
195
195
  version: string;
@@ -19,6 +19,7 @@ const changelog_1 = require("../updaters/changelog");
19
19
  // PHP Specific.
20
20
  const root_composer_update_packages_1 = require("../updaters/php/root-composer-update-packages");
21
21
  const base_1 = require("./base");
22
+ const default_1 = require("../updaters/default");
22
23
  const CHANGELOG_SECTIONS = [
23
24
  { type: 'feat', section: 'Features' },
24
25
  { type: 'fix', section: 'Bug Fixes' },
@@ -60,6 +61,14 @@ class PHP extends base_1.BaseStrategy {
60
61
  versionsMap,
61
62
  }),
62
63
  });
64
+ // update VERSION file
65
+ updates.push({
66
+ path: this.addPath('VERSION'),
67
+ createIfMissing: false,
68
+ updater: new default_1.DefaultUpdater({
69
+ version,
70
+ }),
71
+ });
63
72
  return updates;
64
73
  }
65
74
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "release-please",
3
- "version": "16.3.0",
3
+ "version": "16.4.0",
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",
@@ -47,7 +47,7 @@
47
47
  "@types/jsonpath": "^0.2.0",
48
48
  "@types/mocha": "^9.0.0",
49
49
  "@types/node": "^18.0.0",
50
- "@types/npmlog": "^4.1.4",
50
+ "@types/npmlog": "^7.0.0",
51
51
  "@types/pino": "^7.0.0",
52
52
  "@types/semver": "^7.0.0",
53
53
  "@types/sinon": "^10.0.0",