Skip to content

Commit 57ced8d

Browse files
committed
feat: added argument yes to bump in order to accept questions
* removed unused functions * changed travis to use script test instead of command
1 parent dbdaf07 commit 57ced8d

File tree

3 files changed

+18
-39
lines changed

3 files changed

+18
-39
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ install:
99
- poetry install
1010

1111
script:
12-
- poetry run pytest -s --cov-report term-missing --cov=commitizen tests/
12+
- ./scripts/test
1313

1414
after_success:
1515
- codecov

commitizen/cli.py

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@
6363
"action": "store_true",
6464
"help": "show output to stdout, no commit, no modified files",
6565
},
66+
{
67+
"name": "--yes",
68+
"action": "store_true",
69+
"help": "accept automatically questions done",
70+
},
6671
{
6772
"name": "--tag-format",
6873
"help": (
@@ -95,36 +100,6 @@
95100
}
96101

97102

98-
def load_cfg():
99-
settings = {"name": defaults.name}
100-
config = RawConfigParser("")
101-
home = str(Path.home())
102-
103-
config_file = ".cz"
104-
global_cfg = os.path.join(home, config_file)
105-
106-
# load cfg from current project
107-
configs = ["setup.cfg", ".cz.cfg", config_file, global_cfg]
108-
for cfg in configs:
109-
if not os.path.exists(config_file) and os.path.exists(cfg):
110-
config_file = cfg
111-
112-
config_file_exists = os.path.exists(config_file)
113-
if config_file_exists:
114-
logger.debug('Reading file "%s"', config_file)
115-
config.read_file(io.open(config_file, "rt", encoding="utf-8"))
116-
log_config = io.StringIO()
117-
config.write(log_config)
118-
try:
119-
settings.update(dict(config.items("commitizen")))
120-
break
121-
except NoSectionError:
122-
# The file does not have commitizen section
123-
continue
124-
125-
return settings
126-
127-
128103
def main():
129104
conf = config.read_cfg()
130105
parser = cli(data)

commitizen/commands/bump.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,21 +51,25 @@ def __call__(self):
5151
files: list = self.parameters["files"]
5252
dry_run: bool = self.parameters["dry_run"]
5353

54+
is_yes: bool = self.arguments["yes"]
5455
prerelease: str = self.arguments["prerelease"]
5556
increment: Optional[str] = self.arguments["increment"]
5657
is_initial: bool = False
5758

5859
# Check if reading the whole git tree up to HEAD is needed.
5960
if not git.tag_exist(current_tag_version):
60-
out.info(f"Tag {current_tag_version} could not be found. ")
61-
out.info(
62-
(
63-
"Possible causes:\n"
64-
"- version in configuration is not the current version\n"
65-
"- tag_format is missing, check them using 'git tag --list'\n"
61+
if is_yes:
62+
is_initial = True
63+
else:
64+
out.info(f"Tag {current_tag_version} could not be found. ")
65+
out.info(
66+
(
67+
"Possible causes:\n"
68+
"- version in configuration is not the current version\n"
69+
"- tag_format is missing, check them using 'git tag --list'\n"
70+
)
6671
)
67-
)
68-
is_initial = questionary.confirm("Is this the first tag created?").ask()
72+
is_initial = questionary.confirm("Is this the first tag created?").ask()
6973

7074
commits = git.get_commits(current_tag_version, from_beginning=is_initial)
7175

0 commit comments

Comments
 (0)