Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(bump): new argument --files-only #92

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
woile merged 1 commit into master from feature/bump-files-only
Nov 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions CHANGELOG.md
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 5 additions & 0 deletions commitizen/cli.py
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
26 changes: 17 additions & 9 deletions commitizen/commands/bump.py
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
Expand All @@ -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.
Expand All @@ -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()))
Expand Down
10 changes: 8 additions & 2 deletions docs/bump.md
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

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