release-please 13.4.3 → 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,14 @@
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
+
7
15
  ### [13.4.3](https://github.com/googleapis/release-please/compare/v13.4.2...v13.4.3) (2022-01-24)
8
16
 
9
17
 
@@ -265,10 +265,6 @@ class Manifest {
265
265
  logger_1.logger.debug(`type: ${config.releaseType}`);
266
266
  logger_1.logger.debug(`targetBranch: ${this.targetBranch}`);
267
267
  const pathCommits = commitsAfterSha(path === exports.ROOT_PROJECT_PATH ? commits : commitsPerPath[path], releaseShasByPath[path]);
268
- if (!pathCommits || pathCommits.length === 0) {
269
- logger_1.logger.info(`No commits for path: ${path}, skipping`);
270
- continue;
271
- }
272
268
  logger_1.logger.debug(`commits: ${pathCommits.length}`);
273
269
  const latestReleasePullRequest = releasePullRequestsBySha[releaseShasByPath[path]];
274
270
  if (!latestReleasePullRequest) {
@@ -316,7 +312,6 @@ class Manifest {
316
312
  targetBranch: this.targetBranch,
317
313
  repositoryConfig: this.repositoryConfig,
318
314
  }));
319
- logger_1.logger.info(`separate pull requests: ${this.separatePullRequests}`);
320
315
  // Combine pull requests into 1 unless configured for separate
321
316
  // pull requests
322
317
  if (!this.separatePullRequests) {
@@ -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();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "release-please",
3
- "version": "13.4.3",
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",