Skip to content

Commit ae5a1b1

Browse files
committed
fix: passing tests
corrcet the part of code that do not matched
1 parent 34787a7 commit ae5a1b1

File tree

7 files changed

+19
-6
lines changed

7 files changed

+19
-6
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ repos:
4747
args: [ "--write-changes" ]
4848
additional_dependencies:
4949
- tomli
50-
exclude: "commitizen/cz/conventional_commits/\\.cache_multilanguage\\.txt"
50+
exclude: "commitizen/cz/conventional_commits/cache_multilanguage\\.txt"
5151

5252
- repo: https://github.com/commitizen-tools/commitizen
5353
rev: v4.1.0 # automatically updated by Commitizen

commitizen/cli.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def __call__(
112112
"name": ["-language"],
113113
"type": str,
114114
"default": "en",
115-
"help": "language of the commit message (default: en). Available languages: enGLISH, frENCH. others are welcome",
115+
"help": "Choose the language that you want to use with the conventional format : en, fr, etc",
116116
},
117117
],
118118
"subcommands": {
@@ -181,6 +181,12 @@ def __call__(
181181
"dest": "double_dash",
182182
"help": "Positional arguments separator (recommended)",
183183
},
184+
{
185+
"name": ["-language"],
186+
"type": str,
187+
"default": "en",
188+
"help": "Select a language for the commit message [en/fr/...]",
189+
},
184190
],
185191
},
186192
{

commitizen/commands/commit.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ def read_backup_message(self) -> str | None:
5151
def prompt_commit_questions(self) -> str:
5252
# Prompt user for the commit message
5353
cz = self.cz
54-
questions = cz.questions(self.arguments["language"])
54+
language = "en"
55+
if "language" in self.arguments:
56+
language = self.arguments["language"]
57+
questions = cz.questions(language)
5558
for question in filter(lambda q: q["type"] == "list", questions):
5659
question["use_shortcuts"] = self.config.settings["use_shortcuts"]
5760
try:

commitizen/cz/conventional_commits/.cache_multilanguage.txt renamed to commitizen/cz/conventional_commits/cache_multilanguage.txt

File renamed without changes.

commitizen/cz/conventional_commits/conventional_commits.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class ConventionalCommitsCz(BaseCommitizen):
4343
}
4444
changelog_pattern = defaults.bump_pattern
4545

46-
def questions(self, language: str) -> Questions:
46+
def questions(self, language: str = "en") -> Questions:
4747
questions: Questions = [
4848
{
4949
"type": "list",

commitizen/cz/conventional_commits/translation_multilanguage.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
import os
2+
13
from translate import Translator
24

3-
FILENAME = "commitizen/cz/conventional_commits/.cache_multilanguage.txt"
5+
FILENAME = os.path.join(os.path.dirname(__file__), "cache_multilanguage.txt")
6+
47
IS_TRANSLATING = True
58
MULTILANGUAGE = {}
69

tests/commands/test_commit_command/test_commit_command_shows_description_when_use_help_option.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
usage: cz commit [-h] [--retry] [--no-retry] [--dry-run]
22
[--write-message-to-file FILE_PATH] [-s] [-a] [-e]
3-
[-l MESSAGE_LENGTH_LIMIT] [--]
3+
[-l MESSAGE_LENGTH_LIMIT] [--] [-language LANGUAGE]
44

55
create new commit
66

@@ -20,3 +20,4 @@ options:
2020
-l, --message-length-limit MESSAGE_LENGTH_LIMIT
2121
length limit of the commit message; 0 for no limit
2222
-- Positional arguments separator (recommended)
23+
-language LANGUAGE Select a language for the commit message [en/fr/...]

0 commit comments

Comments
 (0)