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

Commit 7ec8c29

Browse files
committed
feat(bump): new argument --files-only
1 parent 7b634e2 commit 7ec8c29

File tree

4 files changed

+48
-11
lines changed

4 files changed

+48
-11
lines changed

‎CHANGELOG.md‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
# CHANGELOG
22

3+
## v1.10.0
4+
5+
### Feature
6+
7+
- new argument `--files-only` in bump
8+
9+
## v1.9.2
10+
11+
### Fix
12+
13+
- `--commit-msg-file` is now a required argument
14+
15+
## v1.9.1
16+
17+
### Fix
18+
19+
- exception `AnswerRequiredException` not caught
20+
321
## v1.9.0
422

523
### Feature

‎commitizen/cli.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@
7373
"action": "store_true",
7474
"help": "show output to stdout, no commit, no modified files",
7575
},
76+
{
77+
"name": "--files-only",
78+
"action": "store_true",
79+
"help": "bump version in the files from the config",
80+
},
7681
{
7782
"name": "--yes",
7883
"action": "store_true",

‎commitizen/commands/bump.py‎

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,17 @@ def is_initial_tag(self, current_tag_version: str, is_yes: bool = False) -> bool
5252
is_initial = questionary.confirm("Is this the first tag created?").ask()
5353
return is_initial
5454

55+
def find_increment(self, commits: list) -> Optional[str]:
56+
bump_pattern = self.cz.bump_pattern
57+
bump_map = self.cz.bump_map
58+
if not bump_map or not bump_pattern:
59+
out.error(f"'{self.config['name']}' rule does not support bump")
60+
raise SystemExit(NO_PATTERN_MAP)
61+
increment = bump.find_increment(
62+
commits, regex=bump_pattern, increments_map=bump_map
63+
)
64+
return increment
65+
5566
def __call__(self):
5667
"""Steps executed to bump."""
5768
try:
@@ -75,6 +86,7 @@ def __call__(self):
7586
is_yes: bool = self.arguments["yes"]
7687
prerelease: str = self.arguments["prerelease"]
7788
increment: Optional[str] = self.arguments["increment"]
89+
is_files_only: Optional[bool] = self.arguments["files_only"]
7890

7991
is_initial = self.is_initial_tag(current_tag_version, is_yes)
8092
commits = git.get_commits(current_tag_version, from_beginning=is_initial)
@@ -87,14 +99,7 @@ def __call__(self):
8799
raise SystemExit(NO_COMMITS_FOUND)
88100

89101
if increment is None:
90-
bump_pattern = self.cz.bump_pattern
91-
bump_map = self.cz.bump_map
92-
if not bump_map or not bump_pattern:
93-
out.error(f"'{self.config['name']}' rule does not support bump")
94-
raise SystemExit(NO_PATTERN_MAP)
95-
increment = bump.find_increment(
96-
commits, regex=bump_pattern, increments_map=bump_map
97-
)
102+
increment = self.find_increment(commits)
98103

99104
# Increment is removed when current and next version
100105
# are expected to be prereleases.
@@ -118,8 +123,11 @@ def __call__(self):
118123
if dry_run:
119124
raise SystemExit()
120125

121-
config.set_key("version", new_version.public)
122126
bump.update_version_in_files(current_version, new_version.public, files)
127+
if is_files_only:
128+
raise SystemExit()
129+
130+
config.set_key("version", new_version.public)
123131
c = git.commit(message, args="-a")
124132
if c.err:
125133
out.error('git.commit errror: "{}"'.format(c.err.strip()))

‎docs/bump.md‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,22 @@ Some examples:
5454

5555
```bash
5656
$ cz bump --help
57-
usage: cz bump [-h] [--dry-run] [--tag-format TAG_FORMAT]
57+
usage: cz bump [-h] [--dry-run] [--files-only] [--yes]
58+
[--tag-format TAG_FORMAT] [--bump-message BUMP_MESSAGE]
5859
[--prerelease {alpha,beta,rc}]
5960
[--increment {MAJOR,MINOR,PATCH}]
6061

6162
optional arguments:
6263
-h, --help show this help message and exit
6364
--dry-run show output to stdout, no commit, no modified files
65+
--files-only bump version in the files from the config
66+
--yes accept automatically questions done
6467
--tag-format TAG_FORMAT
6568
format used to tag the commmit and read it, use it in
66-
existing projects, wrap around simple quotes.
69+
existing projects, wrap around simple quotes
70+
--bump-message BUMP_MESSAGE
71+
template used to create the release commmit, useful
72+
when working with CI
6773
--prerelease {alpha,beta,rc}, -pr {alpha,beta,rc}
6874
choose type of prerelease
6975
--increment {MAJOR,MINOR,PATCH}

0 commit comments

Comments
(0)

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