Skip to content

Commit

Permalink
feat: Introduce componentNoSpace parameter (Removes whitespace char…
Browse files Browse the repository at this point in the history
…acter 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
  • Loading branch information
Kiruyuto authored Sep 16, 2024
1 parent 9dbe7c6 commit 0a2d5c6
Show file tree
Hide file tree
Showing 14 changed files with 589 additions and 46 deletions.
7 changes: 7 additions & 0 deletions __snapshots__/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ Options:
--pull-request-title-pattern Title pattern to make release PR [string]
--pull-request-header Header for release PR [string]
--pull-request-footer Footer for release PR [string]
--component-no-space release-please automatically adds \` \` (space) in
front of parsed \${component}. Should this be
disabled? [boolean] [default: false]
--path release from path other than root directory
[string]
--component name of component release is being minted for
Expand Down Expand Up @@ -233,6 +236,10 @@ Options:
--pull-request-title-pattern Title pattern to make release PR [string]
--pull-request-header Header for release PR [string]
--pull-request-footer Footer for release PR [string]
--component-no-space release-please automatically adds \` \`
(space) in front of parsed \${component}.
Should this be disabled?
[boolean] [default: false]
--path release from path other than root directory
[string]
--component name of component release is being minted
Expand Down
44 changes: 43 additions & 1 deletion __snapshots__/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,49 @@ exports['Manifest buildPullRequests should allow creating multiple pull requests
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
`

exports['Manifest buildPullRequests should allow customizing pull request title with root package 1'] = `
exports['Manifest buildPullRequests should allow customizing pull request title with root package with SPACE in component 1'] = `
:robot: I have created a release *beep* *boop*
---
<details><summary>root: 1.2.2</summary>
## [1.2.2](https://github.com/fake-owner/fake-repo/compare/root-v1.2.1...root-v1.2.2) (1983-10-10)
### Bug Fixes
* some bugfix ([aaaaaa](https://github.com/fake-owner/fake-repo/commit/aaaaaa))
* some bugfix ([bbbbbb](https://github.com/fake-owner/fake-repo/commit/bbbbbb))
* some bugfix ([cccccc](https://github.com/fake-owner/fake-repo/commit/cccccc))
</details>
<details><summary>pkg1: 1.0.2</summary>
## [1.0.2](https://github.com/fake-owner/fake-repo/compare/pkg1-v1.0.1...pkg1-v1.0.2) (1983-10-10)
### Bug Fixes
* some bugfix ([aaaaaa](https://github.com/fake-owner/fake-repo/commit/aaaaaa))
* some bugfix ([cccccc](https://github.com/fake-owner/fake-repo/commit/cccccc))
</details>
<details><summary>pkg2: 0.2.4</summary>
## [0.2.4](https://github.com/fake-owner/fake-repo/compare/pkg2-v0.2.3...pkg2-v0.2.4) (1983-10-10)
### Bug Fixes
* some bugfix ([bbbbbb](https://github.com/fake-owner/fake-repo/commit/bbbbbb))
</details>
---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
`

exports['Manifest buildPullRequests should allow customizing pull request title with root package without SPACE in component 1'] = `
:robot: I have created a release *beep* *boop*
---
Expand Down
55 changes: 28 additions & 27 deletions docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,33 +39,34 @@ release-please bootstrap \

Extra options:

| Option | Type | Description |
| ------ | ---- | ----------- |
| `--config-file` | `string` | Override the path to the release-please config file. Defaults to `release-please-config.json` |
| `--manifest-file` | `string` | Override the path to the release-please manifest file. Defaults to `.release-please-manifest.json` |
| `--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 `.` |
| `--package-name` | `string` | Name of the package being released. Defaults to a value determined by the configured release type |
| `--component` | `string` | Name of the component used for branch naming and release tagging. Defaults to a normalized version based on the package name |
| `--release-type` | [`ReleaseType`](/docs/customizing.md#strategy-language-types-supported) | Language strategy that determines which files to update |
| `--initial-version` | `string` | Version string to set as the last released version of this package. Defaults to `0.0.0` |
| `--versioning-strategy` | [`VersioningStrategyType`](/docs/customizing.md#versioning-strategies) | Override method of determining SemVer version bumps based on commits. Defaults to `default` |
| `--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 |
| `--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 |
| `--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. |
| `--draft` | `boolean` | If set, create releases as drafts |
| `--prerelease` | `boolean` | If set, create releases that are pre-major or pre-release version marked as pre-release on Github|
| `--draft-pull-request` | `boolean` | If set, create pull requests as drafts |
| `--label` | `string` | Comma-separated list of labels to apply to the release pull requests. Defaults to `autorelease: pending` |
| `--release-label` | `string` | Comma-separated list of labels to apply to the pull request after the release has been tagged. Defaults to `autorelease: tagged` |
| `--changelog-path` | `string` | Override the path to the managed CHANGELOG. Defaults to `CHANGELOG.md` |
| `--changelog-type` | [`ChangelogType`](/docs/customizing.md#changelog-types) | Strategy for building the changelog contents. Defaults to `default` |
| `--changelog-sections` | `string` | Comma-separated list of commit scopes to show in changelog headings |
| `--changelog-host` | `string` | Host for commit hyperlinks in the changelog. Defaults to `https://github.com` |
| `--pull-request-title-pattern` | `string` | Override the pull request title pattern. Defaults to `chore${scope}: release${component} ${version}` |
| `--pull-request-header` | `string` | Override the pull request header. Defaults to `:robot: I have created a release *beep* *boop*` |
| `--pull-request-footer` | `string` | Override the pull request footer. Defaults to `This PR was generated with Release Please. See documentation.` |
| `--extra-files` | `string[]` | Extra file paths for the release strategy to consider |
| `--version-file` | `string` | Ruby only. Path to the `version.rb` file |
| Option | Type | Description |
|------------------------------------|-------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `--config-file` | `string` | Override the path to the release-please config file. Defaults to `release-please-config.json` |
| `--manifest-file` | `string` | Override the path to the release-please manifest file. Defaults to `.release-please-manifest.json` |
| `--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 `.` |
| `--package-name` | `string` | Name of the package being released. Defaults to a value determined by the configured release type |
| `--component` | `string` | Name of the component used for branch naming and release tagging. Defaults to a normalized version based on the package name |
| `--release-type` | [`ReleaseType`](/docs/customizing.md#strategy-language-types-supported) | Language strategy that determines which files to update |
| `--initial-version` | `string` | Version string to set as the last released version of this package. Defaults to `0.0.0` |
| `--versioning-strategy` | [`VersioningStrategyType`](/docs/customizing.md#versioning-strategies) | Override method of determining SemVer version bumps based on commits. Defaults to `default` |
| `--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 |
| `--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 |
| `--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. |
| `--draft` | `boolean` | If set, create releases as drafts |
| `--prerelease` | `boolean` | If set, create releases that are pre-major or pre-release version marked as pre-release on Github |
| `--draft-pull-request` | `boolean` | If set, create pull requests as drafts |
| `--label` | `string` | Comma-separated list of labels to apply to the release pull requests. Defaults to `autorelease: pending` |
| `--release-label` | `string` | Comma-separated list of labels to apply to the pull request after the release has been tagged. Defaults to `autorelease: tagged` |
| `--changelog-path` | `string` | Override the path to the managed CHANGELOG. Defaults to `CHANGELOG.md` |
| `--changelog-type` | [`ChangelogType`](/docs/customizing.md#changelog-types) | Strategy for building the changelog contents. Defaults to `default` |
| `--changelog-sections` | `string` | Comma-separated list of commit scopes to show in changelog headings |
| `--changelog-host` | `string` | Host for commit hyperlinks in the changelog. Defaults to `https://github.com` |
| `--pull-request-title-pattern` | `string` | Override the pull request title pattern. Defaults to `chore${scope}: release${component} ${version}` |
| `--pull-request-header` | `string` | Override the pull request header. Defaults to `:robot: I have created a release *beep* *boop*` |
| `--pull-request-footer` | `string` | Override the pull request footer. Defaults to `This PR was generated with Release Please. See documentation.` |
| `--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` |
| `--extra-files` | `string[]` | Extra file paths for the release strategy to consider |
| `--version-file` | `string` | Ruby only. Path to the `version.rb` file |

## Creating/updating release PRs

Expand Down
8 changes: 7 additions & 1 deletion docs/customizing.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,13 @@ title or body format).

The default pull request title uses this pattern:
`chore${scope}: release${component} ${version}` so a common release pull
request title would be `chore(main): release foo-bar v1.2.3`.
request title would be `chore(main): release foo-bar v1.2.3`.
Please note that by default `${component}` will be parsed to ` ${component}` (With space in front of).
If you wish to avoid that, consider using `component-no-space: true`/`--component-no-space=true` parameter.

> [!WARNING]
> Setting `component-no-space` option when release PR already exists might break the parsing
> resulting in another PR being opened.
| Pattern | Description |
| ------- | ----------- |
Expand Down
11 changes: 10 additions & 1 deletion schemas/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,10 @@
"initial-version": {
"description": "Releases the initial library with a specified version",
"type": "string"
},
"component-no-space": {
"description": "release-please automatically adds ` ` (space) in front of parsed ${component}. This option indicates whether that behaviour should be disabled. Defaults to `false`",
"type": "boolean"
}
}
}
Expand Down Expand Up @@ -423,6 +427,10 @@
"release-label": {
"description": "Comma-separated list of labels to add to a pull request that has been released/tagged",
"type": "string"
},
"component-no-space": {
"description": "release-please automatically adds ` ` (space) in front of parsed ${component}. This option indicates whether that behaviour should be disabled. Defaults to `false`",
"type": "boolean"
}
},
"required": ["packages"]
Expand Down Expand Up @@ -467,6 +475,7 @@
"version-file": true,
"snapshot-label": true,
"initial-version": true,
"exclude-paths": true
"exclude-paths": true,
"component-no-space": false
}
}
8 changes: 8 additions & 0 deletions src/bin/release-please.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ interface TaggingArgs {
pullRequestTitlePattern?: string;
pullRequestHeader?: string;
pullRequestFooter?: string;
componentNoSpace?: boolean;
}

interface CreatePullRequestArgs
Expand Down Expand Up @@ -424,6 +425,12 @@ function taggingOptions(yargs: yargs.Argv): yargs.Argv {
.option('pull-request-footer', {
describe: 'Footer for release PR',
type: 'string',
})
.option('component-no-space', {
describe:
'release-please automatically adds ` ` (space) in front of parsed ${component}. Should this be disabled?',
type: 'boolean',
default: false,
});
}
Expand Down Expand Up @@ -464,6 +471,7 @@ const createReleasePullRequestCommand: yargs.CommandModule<
pullRequestTitlePattern: argv.pullRequestTitlePattern,
pullRequestHeader: argv.pullRequestHeader,
pullRequestFooter: argv.pullRequestFooter,
componentNoSpace: argv.componentNoSpace,
changelogSections: argv.changelogSections,
releaseAs: argv.releaseAs,
versioning: argv.versioningStrategy,
Expand Down
Loading

0 comments on commit 0a2d5c6

Please sign in to comment.