diff --git a/CHANGELOG.md b/CHANGELOG.md index 44a7f8111c..87b2226761 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,23 @@ # CHANGELOG +## v1.10.0 + +### Feature + +- new argument `--files-only` in bump + +## v1.9.2 + +### Fix + +- `--commit-msg-file` is now a required argument + +## v1.9.1 + +### Fix + +- exception `AnswerRequiredException` not caught + ## v1.9.0 ### Feature diff --git a/commitizen/cli.py b/commitizen/cli.py index 7a68aae766..903775b399 100644 --- a/commitizen/cli.py +++ b/commitizen/cli.py @@ -73,6 +73,11 @@ "action": "store_true", "help": "show output to stdout, no commit, no modified files", }, + { + "name": "--files-only", + "action": "store_true", + "help": "bump version in the files from the config", + }, { "name": "--yes", "action": "store_true", diff --git a/commitizen/commands/bump.py b/commitizen/commands/bump.py index d017f8a7a6..27d1dd9ee2 100644 --- a/commitizen/commands/bump.py +++ b/commitizen/commands/bump.py @@ -52,6 +52,17 @@ def is_initial_tag(self, current_tag_version: str, is_yes: bool = False) -> bool is_initial = questionary.confirm("Is this the first tag created?").ask() return is_initial + def find_increment(self, commits: list) -> Optional[str]: + bump_pattern = self.cz.bump_pattern + bump_map = self.cz.bump_map + if not bump_map or not bump_pattern: + out.error(f"'{self.config['name']}' rule does not support bump") + raise SystemExit(NO_PATTERN_MAP) + increment = bump.find_increment( + commits, regex=bump_pattern, increments_map=bump_map + ) + return increment + def __call__(self): """Steps executed to bump.""" try: @@ -75,6 +86,7 @@ def __call__(self): is_yes: bool = self.arguments["yes"] prerelease: str = self.arguments["prerelease"] increment: Optional[str] = self.arguments["increment"] + is_files_only: Optional[bool] = self.arguments["files_only"] is_initial = self.is_initial_tag(current_tag_version, is_yes) commits = git.get_commits(current_tag_version, from_beginning=is_initial) @@ -87,14 +99,7 @@ def __call__(self): raise SystemExit(NO_COMMITS_FOUND) if increment is None: - bump_pattern = self.cz.bump_pattern - bump_map = self.cz.bump_map - if not bump_map or not bump_pattern: - out.error(f"'{self.config['name']}' rule does not support bump") - raise SystemExit(NO_PATTERN_MAP) - increment = bump.find_increment( - commits, regex=bump_pattern, increments_map=bump_map - ) + increment = self.find_increment(commits) # Increment is removed when current and next version # are expected to be prereleases. @@ -118,8 +123,11 @@ def __call__(self): if dry_run: raise SystemExit() - config.set_key("version", new_version.public) bump.update_version_in_files(current_version, new_version.public, files) + if is_files_only: + raise SystemExit() + + config.set_key("version", new_version.public) c = git.commit(message, args="-a") if c.err: out.error('git.commit errror: "{}"'.format(c.err.strip())) diff --git a/docs/bump.md b/docs/bump.md index 6a0a4a542a..fe90322e51 100644 --- a/docs/bump.md +++ b/docs/bump.md @@ -54,16 +54,22 @@ Some examples: ```bash $ cz bump --help -usage: cz bump [-h] [--dry-run] [--tag-format TAG_FORMAT] +usage: cz bump [-h] [--dry-run] [--files-only] [--yes] + [--tag-format TAG_FORMAT] [--bump-message BUMP_MESSAGE] [--prerelease {alpha,beta,rc}] [--increment {MAJOR,MINOR,PATCH}] optional arguments: -h, --help show this help message and exit --dry-run show output to stdout, no commit, no modified files + --files-only bump version in the files from the config + --yes accept automatically questions done --tag-format TAG_FORMAT format used to tag the commmit and read it, use it in - existing projects, wrap around simple quotes. + existing projects, wrap around simple quotes + --bump-message BUMP_MESSAGE + template used to create the release commmit, useful + when working with CI --prerelease {alpha,beta,rc}, -pr {alpha,beta,rc} choose type of prerelease --increment {MAJOR,MINOR,PATCH}

AltStyle によって変換されたページ (->オリジナル) /