release-please 13.4.0 → 13.4.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.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,38 @@
4
4
 
5
5
  [1]: https://www.npmjs.com/package/release-please?activeTab=versions
6
6
 
7
+ ### [13.4.4](https://github.com/googleapis/release-please/compare/v13.4.3...v13.4.4) (2022-01-26)
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * delegate empty commit handling to strategies ([#1254](https://github.com/googleapis/release-please/issues/1254)) ([757f2a9](https://github.com/googleapis/release-please/commit/757f2a9304aec164632ee081b09d22595c5f1e67))
13
+ * extra file should include strategy path ([#1187](https://github.com/googleapis/release-please/issues/1187)) ([c8fffb0](https://github.com/googleapis/release-please/commit/c8fffb0bca7be83487e9d2e3257277e8650cdfaf))
14
+
15
+ ### [13.4.3](https://github.com/googleapis/release-please/compare/v13.4.2...v13.4.3) (2022-01-24)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * multi-component manifest release notes for single component release ([#1247](https://github.com/googleapis/release-please/issues/1247)) ([16aee09](https://github.com/googleapis/release-please/commit/16aee099c79d75853e565f83017745eef13b57fa))
21
+ * release notes should parse initial version heading ([#1248](https://github.com/googleapis/release-please/issues/1248)) ([71dc495](https://github.com/googleapis/release-please/commit/71dc4954e2393f74c4442c021fcf6c8ee530b4ae))
22
+
23
+ ### [13.4.2](https://github.com/googleapis/release-please/compare/v13.4.1...v13.4.2) (2022-01-21)
24
+
25
+
26
+ ### Bug Fixes
27
+
28
+ * Manifest.fromFile no longer ignores manifestFile arg ([#1243](https://github.com/googleapis/release-please/issues/1243)) ([04a44ab](https://github.com/googleapis/release-please/commit/04a44ab08e8ce3911ad814744cebb79aab2ef8aa))
29
+
30
+ ### [13.4.1](https://github.com/googleapis/release-please/compare/v13.4.0...v13.4.1) (2022-01-20)
31
+
32
+
33
+ ### Bug Fixes
34
+
35
+ * handle windows newlines in pull request body ([#1239](https://github.com/googleapis/release-please/issues/1239)) ([69a424f](https://github.com/googleapis/release-please/commit/69a424ff2671ccfb661efd376aede155caee42ce))
36
+ * **python:** fix version regex to find multiple digit patch versions ([#1238](https://github.com/googleapis/release-please/issues/1238)) ([e03a3bf](https://github.com/googleapis/release-please/commit/e03a3bf81f0706b96bc76f217ab420a0f90b4152)), closes [#1237](https://github.com/googleapis/release-please/issues/1237)
37
+ * **python:** restore default changelog config for python ([#1240](https://github.com/googleapis/release-please/issues/1240)) ([54007ea](https://github.com/googleapis/release-please/commit/54007ea6d7d6c12f5757eeb2b5abdf13a8b524be))
38
+
7
39
  ## [13.4.0](https://github.com/googleapis/release-please/compare/v13.3.2...v13.4.0) (2022-01-18)
8
40
 
9
41
 
@@ -93,7 +93,11 @@ class Manifest {
93
93
  parseConfig(github, configFile, targetBranch),
94
94
  parseReleasedVersions(github, manifestFile, targetBranch),
95
95
  ]);
96
- return new Manifest(github, targetBranch, repositoryConfig, releasedVersions, { ...manifestOptions, ...manifestOptionOverrides });
96
+ return new Manifest(github, targetBranch, repositoryConfig, releasedVersions, {
97
+ manifestPath: manifestFile,
98
+ ...manifestOptions,
99
+ ...manifestOptionOverrides,
100
+ });
97
101
  }
98
102
  /**
99
103
  * Create a Manifest from explicit config in code. This assumes that the
@@ -261,10 +265,6 @@ class Manifest {
261
265
  logger_1.logger.debug(`type: ${config.releaseType}`);
262
266
  logger_1.logger.debug(`targetBranch: ${this.targetBranch}`);
263
267
  const pathCommits = commitsAfterSha(path === exports.ROOT_PROJECT_PATH ? commits : commitsPerPath[path], releaseShasByPath[path]);
264
- if (!pathCommits || pathCommits.length === 0) {
265
- logger_1.logger.info(`No commits for path: ${path}, skipping`);
266
- continue;
267
- }
268
268
  logger_1.logger.debug(`commits: ${pathCommits.length}`);
269
269
  const latestReleasePullRequest = releasePullRequestsBySha[releaseShasByPath[path]];
270
270
  if (!latestReleasePullRequest) {
@@ -20,6 +20,7 @@ const pull_request_title_1 = require("../util/pull-request-title");
20
20
  const pull_request_body_1 = require("../util/pull-request-body");
21
21
  const branch_name_1 = require("../util/branch-name");
22
22
  const composite_1 = require("../updaters/composite");
23
+ const logger_1 = require("../util/logger");
23
24
  /**
24
25
  * This plugin merges multiple pull requests into a single
25
26
  * release pull request.
@@ -36,6 +37,7 @@ class Merge extends plugin_1.ManifestPlugin {
36
37
  if (candidates.length < 1) {
37
38
  return candidates;
38
39
  }
40
+ logger_1.logger.info(`Merging ${candidates.length} pull requests`);
39
41
  const releaseData = [];
40
42
  const labels = new Set();
41
43
  let rawUpdates = [];
@@ -54,7 +56,7 @@ class Merge extends plugin_1.ManifestPlugin {
54
56
  const updates = composite_1.mergeUpdates(rawUpdates);
55
57
  const pullRequest = {
56
58
  title: pull_request_title_1.PullRequestTitle.ofComponentTargetBranchVersion(rootRelease === null || rootRelease === void 0 ? void 0 : rootRelease.pullRequest.title.component, this.targetBranch, rootRelease === null || rootRelease === void 0 ? void 0 : rootRelease.pullRequest.title.version, this.pullRequestTitlePattern),
57
- body: new pull_request_body_1.PullRequestBody(releaseData),
59
+ body: new pull_request_body_1.PullRequestBody(releaseData, { useComponents: true }),
58
60
  updates,
59
61
  labels: Array.from(labels),
60
62
  headRefName: branch_name_1.BranchName.ofTargetBranch(this.targetBranch).toString(),
@@ -110,5 +110,11 @@ export declare abstract class BaseStrategy implements Strategy {
110
110
  * Override this to handle the initial version of a new library.
111
111
  */
112
112
  protected initialReleaseVersion(): Version;
113
+ /**
114
+ * Adds a given file path to the strategy path.
115
+ * @param {string} file Desired file path.
116
+ * @returns {string} The file relative to the strategy.
117
+ * @throws {Error} If the file path contains relative pathing characters, i.e. ../, ~/
118
+ */
113
119
  protected addPath(file: string): string;
114
120
  }
@@ -119,6 +119,10 @@ class BaseStrategy {
119
119
  async buildReleasePullRequest(commits, latestRelease, draft, labels = []) {
120
120
  const conventionalCommits = await this.postProcessCommits(commit_1.parseConventionalCommits(commits));
121
121
  logger_1.logger.info(`Considering: ${conventionalCommits.length} commits`);
122
+ if (conventionalCommits.length === 0) {
123
+ logger_1.logger.info(`No commits for path: ${this.path}, skipping`);
124
+ return undefined;
125
+ }
122
126
  const newVersion = await this.buildNewVersion(conventionalCommits, latestRelease);
123
127
  const versionsMap = await this.updateVersionsMap(await this.buildVersionsMap(conventionalCommits), conventionalCommits);
124
128
  const component = await this.getComponent();
@@ -154,13 +158,11 @@ class BaseStrategy {
154
158
  }
155
159
  extraFileUpdates(version) {
156
160
  const genericUpdater = new generic_1.Generic({ version });
157
- return this.extraFiles.map(path => {
158
- return {
159
- path,
160
- createIfMissing: false,
161
- updater: genericUpdater,
162
- };
163
- });
161
+ return this.extraFiles.map(path => ({
162
+ path: this.addPath(path),
163
+ createIfMissing: false,
164
+ updater: genericUpdater,
165
+ }));
164
166
  }
165
167
  changelogEmpty(changelogEntry) {
166
168
  return changelogEntry.split('\n').length <= 1;
@@ -265,18 +267,28 @@ class BaseStrategy {
265
267
  initialReleaseVersion() {
266
268
  return version_1.Version.parse('1.0.0');
267
269
  }
270
+ /**
271
+ * Adds a given file path to the strategy path.
272
+ * @param {string} file Desired file path.
273
+ * @returns {string} The file relative to the strategy.
274
+ * @throws {Error} If the file path contains relative pathing characters, i.e. ../, ~/
275
+ */
268
276
  addPath(file) {
269
- if (this.path === manifest_1.ROOT_PROJECT_PATH) {
270
- return file;
271
- }
272
- file = file.replace(/^[/\\]/, '');
273
- if (this.path === undefined) {
274
- return file;
277
+ // There is no strategy path to join, the strategy is at the root, or the
278
+ // file is at the root (denoted by a leading slash or tilde)
279
+ if (!this.path || this.path === manifest_1.ROOT_PROJECT_PATH || file.startsWith('/')) {
280
+ file = file.replace(/^\/+/, '');
275
281
  }
282
+ // Otherwise, the file is relative to the strategy path
276
283
  else {
277
- const path = this.path.replace(/[/\\]$/, '');
278
- return `${path}/${file}`;
284
+ file = `${this.path.replace(/\/+$/, '')}/${file}`;
285
+ }
286
+ // Ensure the file path does not escape the workspace
287
+ if (/((^|\/)\.{1,2}|^~|^\/*)+\//.test(file)) {
288
+ throw new Error(`illegal pathing characters in path: ${file}`);
279
289
  }
290
+ // Strip any trailing slashes and return
291
+ return file.replace(/\/+$/, '');
280
292
  }
281
293
  }
282
294
  exports.BaseStrategy = BaseStrategy;
@@ -14,6 +14,12 @@ export declare class JavaYoshi extends BaseStrategy {
14
14
  constructor(options: BaseStrategyOptions);
15
15
  buildReleasePullRequest(commits: Commit[], latestRelease?: Release, draft?: boolean, labels?: string[]): Promise<ReleasePullRequest | undefined>;
16
16
  private buildSnapshotPullRequest;
17
+ /**
18
+ * Override this method to post process commits
19
+ * @param {ConventionalCommit[]} commits parsed commits
20
+ * @returns {ConventionalCommit[]} modified commits
21
+ */
22
+ protected postProcessCommits(commits: ConventionalCommit[]): Promise<ConventionalCommit[]>;
17
23
  private needsSnapshot;
18
24
  protected buildVersionsMap(): Promise<VersionsMap>;
19
25
  protected getVersionsContent(): Promise<GitHubFileContents>;
@@ -102,6 +102,29 @@ class JavaYoshi extends base_1.BaseStrategy {
102
102
  draft: false,
103
103
  };
104
104
  }
105
+ /**
106
+ * Override this method to post process commits
107
+ * @param {ConventionalCommit[]} commits parsed commits
108
+ * @returns {ConventionalCommit[]} modified commits
109
+ */
110
+ async postProcessCommits(commits) {
111
+ if (commits.length === 0) {
112
+ // For Java commits, push a fake commit so we force a
113
+ // SNAPSHOT release
114
+ commits.push({
115
+ type: 'fake',
116
+ bareMessage: 'fake commit',
117
+ message: 'fake commit',
118
+ breaking: false,
119
+ scope: null,
120
+ notes: [],
121
+ files: [],
122
+ references: [],
123
+ sha: 'fake',
124
+ });
125
+ }
126
+ return commits;
127
+ }
105
128
  async needsSnapshot() {
106
129
  return versions_manifest_1.VersionsManifest.needsSnapshot((await this.getVersionsContent()).parsedContent);
107
130
  }
@@ -6,7 +6,7 @@ import { ReleasePullRequest } from '../release-pull-request';
6
6
  import { PullRequestBody } from '../util/pull-request-body';
7
7
  export declare class PHPYoshi extends BaseStrategy {
8
8
  constructor(options: BaseStrategyOptions);
9
- buildReleasePullRequest(commits: Commit[], latestRelease?: Release, draft?: boolean, labels?: string[]): Promise<ReleasePullRequest>;
9
+ buildReleasePullRequest(commits: Commit[], latestRelease?: Release, draft?: boolean, labels?: string[]): Promise<ReleasePullRequest | undefined>;
10
10
  protected parsePullRequestBody(pullRequestBody: string): Promise<PullRequestBody | undefined>;
11
11
  protected buildUpdates(options: BuildUpdatesOptions): Promise<Update[]>;
12
12
  }
@@ -51,6 +51,10 @@ class PHPYoshi extends base_1.BaseStrategy {
51
51
  async buildReleasePullRequest(commits, latestRelease, draft, labels = []) {
52
52
  var _a, _b, _c;
53
53
  const conventionalCommits = await this.postProcessCommits(commit_1.parseConventionalCommits(commits));
54
+ if (conventionalCommits.length === 0) {
55
+ logger_1.logger.info(`No commits for path: ${this.path}, skipping`);
56
+ return undefined;
57
+ }
54
58
  const newVersion = latestRelease
55
59
  ? await this.versioningStrategy.bump(latestRelease.tag.version, conventionalCommits)
56
60
  : this.initialReleaseVersion();
@@ -1,7 +1,8 @@
1
- import { BaseStrategy, BuildUpdatesOptions } from './base';
1
+ import { BaseStrategy, BuildUpdatesOptions, BaseStrategyOptions } from './base';
2
2
  import { Update } from '../update';
3
3
  import { Version } from '../version';
4
4
  export declare class Python extends BaseStrategy {
5
+ constructor(options: BaseStrategyOptions);
5
6
  protected buildUpdates(options: BuildUpdatesOptions): Promise<Update[]>;
6
7
  private getPyProject;
7
8
  protected initialReleaseVersion(): Version;
@@ -22,7 +22,26 @@ const setup_py_1 = require("../updaters/python/setup-py");
22
22
  const pyproject_toml_1 = require("../updaters/python/pyproject-toml");
23
23
  const logger_1 = require("../util/logger");
24
24
  const python_file_with_version_1 = require("../updaters/python/python-file-with-version");
25
+ const CHANGELOG_SECTIONS = [
26
+ { type: 'feat', section: 'Features' },
27
+ { type: 'fix', section: 'Bug Fixes' },
28
+ { type: 'perf', section: 'Performance Improvements' },
29
+ { type: 'deps', section: 'Dependencies' },
30
+ { type: 'revert', section: 'Reverts' },
31
+ { type: 'docs', section: 'Documentation' },
32
+ { type: 'style', section: 'Styles', hidden: true },
33
+ { type: 'chore', section: 'Miscellaneous Chores', hidden: true },
34
+ { type: 'refactor', section: 'Code Refactoring', hidden: true },
35
+ { type: 'test', section: 'Tests', hidden: true },
36
+ { type: 'build', section: 'Build System', hidden: true },
37
+ { type: 'ci', section: 'Continuous Integration', hidden: true },
38
+ ];
25
39
  class Python extends base_1.BaseStrategy {
40
+ constructor(options) {
41
+ var _a;
42
+ options.changelogSections = (_a = options.changelogSections) !== null && _a !== void 0 ? _a : CHANGELOG_SECTIONS;
43
+ super(options);
44
+ }
26
45
  async buildUpdates(options) {
27
46
  var _a;
28
47
  const updates = [];
@@ -25,7 +25,7 @@ class SetupPy extends default_1.DefaultUpdater {
25
25
  * @returns {string} The updated content
26
26
  */
27
27
  updateContent(content) {
28
- return content.replace(/(version ?= ?["'])[0-9]+\.[0-9]+\.[0-9](?:-\w+)?(["'])/, `$1${this.version}$2`);
28
+ return content.replace(/(version ?= ?["'])[0-9]+\.[0-9]+\.[0-9]+(?:-\w+)?(["'])/, `$1${this.version}$2`);
29
29
  }
30
30
  }
31
31
  exports.SetupPy = SetupPy;
@@ -3,12 +3,14 @@ interface PullRequestBodyOptions {
3
3
  header?: string;
4
4
  footer?: string;
5
5
  extra?: string;
6
+ useComponents?: boolean;
6
7
  }
7
8
  export declare class PullRequestBody {
8
9
  header: string;
9
10
  footer: string;
10
11
  extra?: string;
11
12
  releaseData: ReleaseData[];
13
+ useComponents: boolean;
12
14
  constructor(releaseData: ReleaseData[], options?: PullRequestBodyOptions);
13
15
  static parse(body: string): PullRequestBody | undefined;
14
16
  notes(): string;
@@ -22,10 +22,12 @@ const DEFAULT_FOOTER = 'This PR was generated with [Release Please](https://gith
22
22
  const NOTES_DELIMITER = '---';
23
23
  class PullRequestBody {
24
24
  constructor(releaseData, options) {
25
+ var _a;
25
26
  this.header = (options === null || options === void 0 ? void 0 : options.header) || DEFAULT_HEADER;
26
27
  this.footer = (options === null || options === void 0 ? void 0 : options.footer) || DEFAULT_FOOTER;
27
28
  this.extra = options === null || options === void 0 ? void 0 : options.extra;
28
29
  this.releaseData = releaseData;
30
+ this.useComponents = (_a = options === null || options === void 0 ? void 0 : options.useComponents) !== null && _a !== void 0 ? _a : this.releaseData.length > 1;
29
31
  }
30
32
  static parse(body) {
31
33
  const parts = splitBody(body);
@@ -46,7 +48,7 @@ class PullRequestBody {
46
48
  });
47
49
  }
48
50
  notes() {
49
- if (this.releaseData.length > 1) {
51
+ if (this.useComponents) {
50
52
  return this.releaseData
51
53
  .map(release => {
52
54
  var _a;
@@ -70,7 +72,7 @@ ${this.footer}`;
70
72
  }
71
73
  exports.PullRequestBody = PullRequestBody;
72
74
  function splitBody(body) {
73
- const lines = body.trim().split('\n');
75
+ const lines = body.trim().replace(/\r\n/g, '\n').split('\n');
74
76
  const index = lines.indexOf(NOTES_DELIMITER);
75
77
  if (index === -1) {
76
78
  return undefined;
@@ -110,7 +112,7 @@ function extractMultipleReleases(notes) {
110
112
  }
111
113
  return data;
112
114
  }
113
- const COMPARE_REGEX = /^#{2,} \[(?<version>\d+\.\d+\.\d+.*)\]/;
115
+ const COMPARE_REGEX = /^#{2,} \[?(?<version>\d+\.\d+\.\d+.*)\]?/;
114
116
  function extractSingleRelease(body) {
115
117
  var _a;
116
118
  body = body.trim();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "release-please",
3
- "version": "13.4.0",
3
+ "version": "13.4.4",
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",