Skip to content

Commit 3b1681e

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

File tree

3 files changed

+40
-9
lines changed

3 files changed

+40
-9
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()))

0 commit comments

Comments
 (0)