Skip to content

Commit 0a2d5c6

Browse files
authored
feat: Introduce componentNoSpace parameter (Removes whitespace character from ${component} title pattern) (#2330)
* fix: Remove space from pull-request-title.ts * test: Fix failing tests * feat: Introduce new parameter `componentNoSpace`; Partially revert previous changes * feat: Update docs * chore: Remove unnecessary `console.log()` * style: Run `npm fix` across the project * chore: Update snapshots * feat: Add `componentNoSpace` parameter to merge plugin * style: Adjust code style; Run `npm fix` * fix: Docs parameter name
1 parent 9dbe7c6 commit 0a2d5c6

14 files changed

Lines changed: 589 additions & 46 deletions

File tree

__snapshots__/cli.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ Options:
3232
--pull-request-title-pattern Title pattern to make release PR [string]
3333
--pull-request-header Header for release PR [string]
3434
--pull-request-footer Footer for release PR [string]
35+
--component-no-space release-please automatically adds \` \` (space) in
36+
front of parsed \${component}. Should this be
37+
disabled? [boolean] [default: false]
3538
--path release from path other than root directory
3639
[string]
3740
--component name of component release is being minted for
@@ -233,6 +236,10 @@ Options:
233236
--pull-request-title-pattern Title pattern to make release PR [string]
234237
--pull-request-header Header for release PR [string]
235238
--pull-request-footer Footer for release PR [string]
239+
--component-no-space release-please automatically adds \` \`
240+
(space) in front of parsed \${component}.
241+
Should this be disabled?
242+
[boolean] [default: false]
236243
--path release from path other than root directory
237244
[string]
238245
--component name of component release is being minted

__snapshots__/manifest.js

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,49 @@ exports['Manifest buildPullRequests should allow creating multiple pull requests
3030
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
3131
`
3232

33-
exports['Manifest buildPullRequests should allow customizing pull request title with root package 1'] = `
33+
exports['Manifest buildPullRequests should allow customizing pull request title with root package with SPACE in component 1'] = `
34+
:robot: I have created a release *beep* *boop*
35+
---
36+
37+
38+
<details><summary>root: 1.2.2</summary>
39+
40+
## [1.2.2](https://github.com/fake-owner/fake-repo/compare/root-v1.2.1...root-v1.2.2) (1983-10-10)
41+
42+
43+
### Bug Fixes
44+
45+
* some bugfix ([aaaaaa](https://github.com/fake-owner/fake-repo/commit/aaaaaa))
46+
* some bugfix ([bbbbbb](https://github.com/fake-owner/fake-repo/commit/bbbbbb))
47+
* some bugfix ([cccccc](https://github.com/fake-owner/fake-repo/commit/cccccc))
48+
</details>
49+
50+
<details><summary>pkg1: 1.0.2</summary>
51+
52+
## [1.0.2](https://github.com/fake-owner/fake-repo/compare/pkg1-v1.0.1...pkg1-v1.0.2) (1983-10-10)
53+
54+
55+
### Bug Fixes
56+
57+
* some bugfix ([aaaaaa](https://github.com/fake-owner/fake-repo/commit/aaaaaa))
58+
* some bugfix ([cccccc](https://github.com/fake-owner/fake-repo/commit/cccccc))
59+
</details>
60+
61+
<details><summary>pkg2: 0.2.4</summary>
62+
63+
## [0.2.4](https://github.com/fake-owner/fake-repo/compare/pkg2-v0.2.3...pkg2-v0.2.4) (1983-10-10)
64+
65+
66+
### Bug Fixes
67+
68+
* some bugfix ([bbbbbb](https://github.com/fake-owner/fake-repo/commit/bbbbbb))
69+
</details>
70+
71+
---
72+
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
73+
`
74+
75+
exports['Manifest buildPullRequests should allow customizing pull request title with root package without SPACE in component 1'] = `
3476
:robot: I have created a release *beep* *boop*
3577
---
3678

docs/cli.md

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -39,33 +39,34 @@ release-please bootstrap \
3939

4040
Extra options:
4141

42-
| Option | Type | Description |
43-
| ------ | ---- | ----------- |
44-
| `--config-file` | `string` | Override the path to the release-please config file. Defaults to `release-please-config.json` |
45-
| `--manifest-file` | `string` | Override the path to the release-please manifest file. Defaults to `.release-please-manifest.json` |
46-
| `--path` | `string` | Path for changes to consider part of this component's release. Defaults to `.` Other paths should be relative to the repository root and not include `.` |
47-
| `--package-name` | `string` | Name of the package being released. Defaults to a value determined by the configured release type |
48-
| `--component` | `string` | Name of the component used for branch naming and release tagging. Defaults to a normalized version based on the package name |
49-
| `--release-type` | [`ReleaseType`](/docs/customizing.md#strategy-language-types-supported) | Language strategy that determines which files to update |
50-
| `--initial-version` | `string` | Version string to set as the last released version of this package. Defaults to `0.0.0` |
51-
| `--versioning-strategy` | [`VersioningStrategyType`](/docs/customizing.md#versioning-strategies) | Override method of determining SemVer version bumps based on commits. Defaults to `default` |
52-
| `--bump-minor-pre-major` | `boolean` | Configuration option for the versioning strategy. If set, will bump the minor version for breaking changes for versions < 1.0.0 |
53-
| `--bump-patch-for-minor-pre-major` | `boolean` | Configuration option for the versioning strategy. If set, will bump the patch version for features for versions < 1.0.0 |
54-
| `--prerelease-type` | `string` | Configuration option for the prerelease versioning strategy. If prerelease strategy used and type set, will set the prerelease part of the version to the provided value in case prerelease part is not present. |
55-
| `--draft` | `boolean` | If set, create releases as drafts |
56-
| `--prerelease` | `boolean` | If set, create releases that are pre-major or pre-release version marked as pre-release on Github|
57-
| `--draft-pull-request` | `boolean` | If set, create pull requests as drafts |
58-
| `--label` | `string` | Comma-separated list of labels to apply to the release pull requests. Defaults to `autorelease: pending` |
59-
| `--release-label` | `string` | Comma-separated list of labels to apply to the pull request after the release has been tagged. Defaults to `autorelease: tagged` |
60-
| `--changelog-path` | `string` | Override the path to the managed CHANGELOG. Defaults to `CHANGELOG.md` |
61-
| `--changelog-type` | [`ChangelogType`](/docs/customizing.md#changelog-types) | Strategy for building the changelog contents. Defaults to `default` |
62-
| `--changelog-sections` | `string` | Comma-separated list of commit scopes to show in changelog headings |
63-
| `--changelog-host` | `string` | Host for commit hyperlinks in the changelog. Defaults to `https://github.com` |
64-
| `--pull-request-title-pattern` | `string` | Override the pull request title pattern. Defaults to `chore${scope}: release${component} ${version}` |
65-
| `--pull-request-header` | `string` | Override the pull request header. Defaults to `:robot: I have created a release *beep* *boop*` |
66-
| `--pull-request-footer` | `string` | Override the pull request footer. Defaults to `This PR was generated with Release Please. See documentation.` |
67-
| `--extra-files` | `string[]` | Extra file paths for the release strategy to consider |
68-
| `--version-file` | `string` | Ruby only. Path to the `version.rb` file |
42+
| Option | Type | Description |
43+
|------------------------------------|-------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
44+
| `--config-file` | `string` | Override the path to the release-please config file. Defaults to `release-please-config.json` |
45+
| `--manifest-file` | `string` | Override the path to the release-please manifest file. Defaults to `.release-please-manifest.json` |
46+
| `--path` | `string` | Path for changes to consider part of this component's release. Defaults to `.` Other paths should be relative to the repository root and not include `.` |
47+
| `--package-name` | `string` | Name of the package being released. Defaults to a value determined by the configured release type |
48+
| `--component` | `string` | Name of the component used for branch naming and release tagging. Defaults to a normalized version based on the package name |
49+
| `--release-type` | [`ReleaseType`](/docs/customizing.md#strategy-language-types-supported) | Language strategy that determines which files to update |
50+
| `--initial-version` | `string` | Version string to set as the last released version of this package. Defaults to `0.0.0` |
51+
| `--versioning-strategy` | [`VersioningStrategyType`](/docs/customizing.md#versioning-strategies) | Override method of determining SemVer version bumps based on commits. Defaults to `default` |
52+
| `--bump-minor-pre-major` | `boolean` | Configuration option for the versioning strategy. If set, will bump the minor version for breaking changes for versions < 1.0.0 |
53+
| `--bump-patch-for-minor-pre-major` | `boolean` | Configuration option for the versioning strategy. If set, will bump the patch version for features for versions < 1.0.0 |
54+
| `--prerelease-type` | `string` | Configuration option for the prerelease versioning strategy. If prerelease strategy used and type set, will set the prerelease part of the version to the provided value in case prerelease part is not present. |
55+
| `--draft` | `boolean` | If set, create releases as drafts |
56+
| `--prerelease` | `boolean` | If set, create releases that are pre-major or pre-release version marked as pre-release on Github |
57+
| `--draft-pull-request` | `boolean` | If set, create pull requests as drafts |
58+
| `--label` | `string` | Comma-separated list of labels to apply to the release pull requests. Defaults to `autorelease: pending` |
59+
| `--release-label` | `string` | Comma-separated list of labels to apply to the pull request after the release has been tagged. Defaults to `autorelease: tagged` |
60+
| `--changelog-path` | `string` | Override the path to the managed CHANGELOG. Defaults to `CHANGELOG.md` |
61+
| `--changelog-type` | [`ChangelogType`](/docs/customizing.md#changelog-types) | Strategy for building the changelog contents. Defaults to `default` |
62+
| `--changelog-sections` | `string` | Comma-separated list of commit scopes to show in changelog headings |
63+
| `--changelog-host` | `string` | Host for commit hyperlinks in the changelog. Defaults to `https://github.com` |
64+
| `--pull-request-title-pattern` | `string` | Override the pull request title pattern. Defaults to `chore${scope}: release${component} ${version}` |
65+
| `--pull-request-header` | `string` | Override the pull request header. Defaults to `:robot: I have created a release *beep* *boop*` |
66+
| `--pull-request-footer` | `string` | Override the pull request footer. Defaults to `This PR was generated with Release Please. See documentation.` |
67+
| `--component-no-space` | `boolean` | release-please automatically adds ` ` (space) in front of parsed ${component}. This option indicates whether that behaviour should be disabled. Defaults to `false` |
68+
| `--extra-files` | `string[]` | Extra file paths for the release strategy to consider |
69+
| `--version-file` | `string` | Ruby only. Path to the `version.rb` file |
6970

7071
## Creating/updating release PRs
7172

docs/customizing.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,13 @@ title or body format).
101101

102102
The default pull request title uses this pattern:
103103
`chore${scope}: release${component} ${version}` so a common release pull
104-
request title would be `chore(main): release foo-bar v1.2.3`.
104+
request title would be `chore(main): release foo-bar v1.2.3`.
105+
Please note that by default `${component}` will be parsed to ` ${component}` (With space in front of).
106+
If you wish to avoid that, consider using `component-no-space: true`/`--component-no-space=true` parameter.
107+
108+
> [!WARNING]
109+
> Setting `component-no-space` option when release PR already exists might break the parsing
110+
> resulting in another PR being opened.
105111
106112
| Pattern | Description |
107113
| ------- | ----------- |

schemas/config.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,10 @@
233233
"initial-version": {
234234
"description": "Releases the initial library with a specified version",
235235
"type": "string"
236+
},
237+
"component-no-space": {
238+
"description": "release-please automatically adds ` ` (space) in front of parsed ${component}. This option indicates whether that behaviour should be disabled. Defaults to `false`",
239+
"type": "boolean"
236240
}
237241
}
238242
}
@@ -423,6 +427,10 @@
423427
"release-label": {
424428
"description": "Comma-separated list of labels to add to a pull request that has been released/tagged",
425429
"type": "string"
430+
},
431+
"component-no-space": {
432+
"description": "release-please automatically adds ` ` (space) in front of parsed ${component}. This option indicates whether that behaviour should be disabled. Defaults to `false`",
433+
"type": "boolean"
426434
}
427435
},
428436
"required": ["packages"]
@@ -467,6 +475,7 @@
467475
"version-file": true,
468476
"snapshot-label": true,
469477
"initial-version": true,
470-
"exclude-paths": true
478+
"exclude-paths": true,
479+
"component-no-space": false
471480
}
472481
}

src/bin/release-please.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ interface TaggingArgs {
116116
pullRequestTitlePattern?: string;
117117
pullRequestHeader?: string;
118118
pullRequestFooter?: string;
119+
componentNoSpace?: boolean;
119120
}
120121

121122
interface CreatePullRequestArgs
@@ -424,6 +425,12 @@ function taggingOptions(yargs: yargs.Argv): yargs.Argv {
424425
.option('pull-request-footer', {
425426
describe: 'Footer for release PR',
426427
type: 'string',
428+
})
429+
.option('component-no-space', {
430+
describe:
431+
'release-please automatically adds ` ` (space) in front of parsed ${component}. Should this be disabled?',
432+
type: 'boolean',
433+
default: false,
427434
});
428435
}
429436

@@ -464,6 +471,7 @@ const createReleasePullRequestCommand: yargs.CommandModule<
464471
pullRequestTitlePattern: argv.pullRequestTitlePattern,
465472
pullRequestHeader: argv.pullRequestHeader,
466473
pullRequestFooter: argv.pullRequestFooter,
474+
componentNoSpace: argv.componentNoSpace,
467475
changelogSections: argv.changelogSections,
468476
releaseAs: argv.releaseAs,
469477
versioning: argv.versioningStrategy,

0 commit comments

Comments
 (0)