release-please 13.1.0 → 13.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
+ ### [13.1.1](https://www.github.com/googleapis/release-please/compare/v13.1.0...v13.1.1) (2022-01-03)
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * **rust:** Rust strategy should update root Cargo files in a workspace ([#1182](https://www.github.com/googleapis/release-please/issues/1182)) ([26a040c](https://www.github.com/googleapis/release-please/commit/26a040cf06a7a2cf97b9ebc3d204bb36f0b2c13b)), closes [#1170](https://www.github.com/googleapis/release-please/issues/1170) [#1096](https://www.github.com/googleapis/release-please/issues/1096)
13
+
7
14
  ## [13.1.0](https://www.github.com/googleapis/release-please/compare/v13.0.2...v13.1.0) (2021-12-29)
8
15
 
9
16
 
package/README.md CHANGED
@@ -91,6 +91,24 @@ chore: release 2.0.0
91
91
  Release-As: 2.0.0
92
92
  ```
93
93
 
94
+ ## How can I fix release notes?
95
+
96
+ If you have merged a pull request and you would like to amend the commit message
97
+ used to generate the release notes for that commit, you can edit the body of
98
+ the merged pull requests and add a section like:
99
+
100
+ ```
101
+ BEGIN_COMMIT_OVERRIDE
102
+ feat: add ability to override merged commit message
103
+
104
+ fix: another message
105
+ chore: a third message
106
+ END_COMMIT_OVERRIDE
107
+ ```
108
+
109
+ The next time release please runs, it will use that override section as the
110
+ commit message instead of the merged commit message.
111
+
94
112
  ## Strategy (Language) types supported
95
113
 
96
114
  Release Please automates releases for the following flavors of repositories:
@@ -26,6 +26,7 @@ const pull_request_title_1 = require("../util/pull-request-title");
26
26
  const pull_request_body_1 = require("../util/pull-request-body");
27
27
  const branch_name_1 = require("../util/branch-name");
28
28
  const versioning_strategy_1 = require("../versioning-strategy");
29
+ const cargo_lock_1 = require("../updaters/rust/cargo-lock");
29
30
  /**
30
31
  * The plugin analyzed a cargo workspace and will bump dependencies
31
32
  * of managed packages if those dependencies are being updated.
@@ -50,7 +51,9 @@ class CargoWorkspace extends workspace_1.WorkspacePlugin {
50
51
  }
51
52
  const allCrates = [];
52
53
  const candidatesByPackage = {};
53
- for (const path of cargoManifest.workspace.members) {
54
+ const members = cargoManifest.workspace.members;
55
+ members.push(manifest_1.ROOT_PROJECT_PATH);
56
+ for (const path of members) {
54
57
  const manifestPath = addPath(path, 'Cargo.toml');
55
58
  logger_1.logger.info(`looking for candidate with path: ${path}`);
56
59
  const candidate = candidates.find(c => c.path === path);
@@ -60,7 +63,8 @@ class CargoWorkspace extends workspace_1.WorkspacePlugin {
60
63
  const manifest = common_1.parseCargoManifest(manifestContent.parsedContent);
61
64
  const packageName = (_c = manifest.package) === null || _c === void 0 ? void 0 : _c.name;
62
65
  if (!packageName) {
63
- throw new Error(`package manifest at ${manifestPath} is missing [package.name]`);
66
+ logger_1.logger.warn(`package manifest at ${manifestPath} is missing [package.name]`);
67
+ continue;
64
68
  }
65
69
  if (candidate) {
66
70
  candidatesByPackage[packageName] = candidate;
@@ -105,9 +109,15 @@ class CargoWorkspace extends workspace_1.WorkspacePlugin {
105
109
  if (update.path === addPath(existingCandidate.path, 'Cargo.toml')) {
106
110
  update.updater = new raw_content_1.RawContent(updatedContent);
107
111
  }
108
- else if (update.updater instanceof changelog_1.Changelog) {
112
+ else if (update.updater instanceof changelog_1.Changelog && dependencyNotes) {
109
113
  update.updater.changelogEntry = appendDependenciesSectionToChangelog(update.updater.changelogEntry, dependencyNotes);
110
114
  }
115
+ else if (update.path === addPath(existingCandidate.path, 'Cargo.lock')) {
116
+ update.updater = new cargo_lock_1.CargoLock({
117
+ version,
118
+ versionsMap: updatedVersions,
119
+ });
120
+ }
111
121
  return update;
112
122
  });
113
123
  // append dependency notes
@@ -195,8 +205,7 @@ class CargoWorkspace extends workspace_1.WorkspacePlugin {
195
205
  return graph;
196
206
  }
197
207
  inScope(candidate) {
198
- return (candidate.config.releaseType === 'rust' &&
199
- candidate.path !== manifest_1.ROOT_PROJECT_PATH);
208
+ return candidate.config.releaseType === 'rust';
200
209
  }
201
210
  packageNameFromPackage(pkg) {
202
211
  return pkg.name;
@@ -12,9 +12,6 @@ export declare class Rust extends BaseStrategy {
12
12
  * @returns the package's manifest, ie. `crates/foobar/Cargo.toml`
13
13
  */
14
14
  protected getPackageManifest(): Promise<CargoManifest | null>;
15
- /**
16
- * @returns the workspace's manifest, ie. `Cargo.toml` (top-level)
17
- */
18
- protected getWorkspaceManifest(): Promise<CargoManifest | null>;
15
+ private getContent;
19
16
  protected getManifest(path: string): Promise<CargoManifest | null>;
20
17
  }
@@ -25,6 +25,7 @@ const base_1 = require("./base");
25
25
  const version_1 = require("../version");
26
26
  class Rust extends base_1.BaseStrategy {
27
27
  async buildUpdates(options) {
28
+ var _a, _b, _c;
28
29
  const updates = [];
29
30
  const version = options.newVersion;
30
31
  updates.push({
@@ -35,30 +36,62 @@ class Rust extends base_1.BaseStrategy {
35
36
  changelogEntry: options.changelogEntry,
36
37
  }),
37
38
  });
38
- const workspaceManifest = await this.getWorkspaceManifest();
39
- const manifestPaths = [];
40
- let lockPath;
41
- if (workspaceManifest &&
42
- workspaceManifest.workspace &&
43
- workspaceManifest.workspace.members) {
39
+ const workspaceManifest = await this.getPackageManifest();
40
+ const versionsMap = new Map();
41
+ if ((_a = workspaceManifest === null || workspaceManifest === void 0 ? void 0 : workspaceManifest.workspace) === null || _a === void 0 ? void 0 : _a.members) {
44
42
  const members = workspaceManifest.workspace.members;
43
+ if ((_b = workspaceManifest.package) === null || _b === void 0 ? void 0 : _b.name) {
44
+ versionsMap.set(workspaceManifest.package.name, version);
45
+ }
46
+ else {
47
+ logger_1.logger.warn('No workspace manifest package name found');
48
+ }
45
49
  logger_1.logger.info(`found workspace with ${members.length} members, upgrading all`);
50
+ // Collect submodule names to update
51
+ const manifestsByPath = new Map();
46
52
  for (const member of members) {
47
- manifestPaths.push(`${member}/Cargo.toml`);
53
+ const manifestPath = `${member}/Cargo.toml`;
54
+ const manifestContent = await this.getContent(manifestPath);
55
+ if (!manifestContent) {
56
+ logger_1.logger.warn(`member ${member} declared but did not find Cargo.toml`);
57
+ continue;
58
+ }
59
+ const manifest = common_1.parseCargoManifest(manifestContent.parsedContent);
60
+ manifestsByPath.set(manifestPath, manifestContent);
61
+ if (!((_c = manifest.package) === null || _c === void 0 ? void 0 : _c.name)) {
62
+ logger_1.logger.warn(`member ${member} has no package name`);
63
+ continue;
64
+ }
65
+ versionsMap.set(manifest.package.name, version);
48
66
  }
49
- lockPath = 'Cargo.lock';
67
+ logger_1.logger.info(`updating ${manifestsByPath.size} submodules`);
68
+ logger_1.logger.debug('versions map:', versionsMap);
69
+ for (const [manifestPath, manifestContent] of manifestsByPath) {
70
+ updates.push({
71
+ path: this.addPath(manifestPath),
72
+ createIfMissing: false,
73
+ cachedFileContents: manifestContent,
74
+ updater: new cargo_toml_1.CargoToml({
75
+ version,
76
+ versionsMap,
77
+ }),
78
+ });
79
+ }
80
+ // Update root Cargo.toml
81
+ updates.push({
82
+ path: this.addPath('Cargo.toml'),
83
+ createIfMissing: false,
84
+ updater: new cargo_toml_1.CargoToml({
85
+ version,
86
+ versionsMap,
87
+ }),
88
+ });
50
89
  }
51
90
  else {
52
91
  const manifestPath = this.addPath('Cargo.toml');
53
92
  logger_1.logger.info(`single crate found, updating ${manifestPath}`);
54
- manifestPaths.push(manifestPath);
55
- lockPath = this.addPath('Cargo.lock');
56
- }
57
- const versionsMap = new Map();
58
- versionsMap.set(this.component || '', version);
59
- for (const path of manifestPaths) {
60
93
  updates.push({
61
- path,
94
+ path: manifestPath,
62
95
  createIfMissing: false,
63
96
  updater: new cargo_toml_1.CargoToml({
64
97
  version,
@@ -67,7 +100,7 @@ class Rust extends base_1.BaseStrategy {
67
100
  });
68
101
  }
69
102
  updates.push({
70
- path: lockPath,
103
+ path: this.addPath('Cargo.lock'),
71
104
  createIfMissing: false,
72
105
  updater: new cargo_lock_1.CargoLock({
73
106
  version,
@@ -92,28 +125,21 @@ class Rust extends base_1.BaseStrategy {
92
125
  */
93
126
  async getPackageManifest() {
94
127
  if (this.packageManifest === undefined) {
95
- this.packageManifest = await this.getManifest(this.addPath('Cargo.toml'));
128
+ this.packageManifest = await this.getManifest('Cargo.toml');
96
129
  }
97
130
  return this.packageManifest;
98
131
  }
99
- /**
100
- * @returns the workspace's manifest, ie. `Cargo.toml` (top-level)
101
- */
102
- async getWorkspaceManifest() {
103
- if (this.workspaceManifest === undefined) {
104
- this.workspaceManifest = await this.getManifest('Cargo.toml');
105
- }
106
- return this.workspaceManifest;
107
- }
108
- async getManifest(path) {
109
- let content;
132
+ async getContent(path) {
110
133
  try {
111
- content = await this.github.getFileContentsOnBranch(path, this.targetBranch);
134
+ return await this.github.getFileContentsOnBranch(this.addPath(path), this.targetBranch);
112
135
  }
113
136
  catch (e) {
114
137
  return null;
115
138
  }
116
- return common_1.parseCargoManifest(content.parsedContent);
139
+ }
140
+ async getManifest(path) {
141
+ const content = await this.getContent(path);
142
+ return content ? common_1.parseCargoManifest(content.parsedContent) : null;
117
143
  }
118
144
  }
119
145
  exports.Rust = Rust;
@@ -28,7 +28,6 @@ class CargoToml extends default_1.DefaultUpdater {
28
28
  * @returns {string} The updated content
29
29
  */
30
30
  updateContent(content) {
31
- var _a;
32
31
  let payload = content;
33
32
  if (!this.versionsMap) {
34
33
  throw new Error('updateContent called with no versions');
@@ -39,12 +38,8 @@ class CargoToml extends default_1.DefaultUpdater {
39
38
  logger_1.logger.error(msg);
40
39
  throw new Error(msg);
41
40
  }
41
+ payload = toml_edit_1.replaceTomlValue(payload, ['package', 'version'], this.version.toString());
42
42
  for (const [pkgName, pkgVersion] of this.versionsMap) {
43
- if (parsed.package.name === pkgName) {
44
- logger_1.logger.info(`updating own version from ${(_a = parsed.package) === null || _a === void 0 ? void 0 : _a.version} to ${pkgVersion}`);
45
- payload = toml_edit_1.replaceTomlValue(payload, ['package', 'version'], pkgVersion.toString());
46
- continue; // to next [pkgName, pkgVersion] pair
47
- }
48
43
  for (const depKind of common_1.DEP_KINDS) {
49
44
  const deps = parsed[depKind];
50
45
  if (!deps) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "release-please",
3
- "version": "13.1.0",
3
+ "version": "13.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",