Skip to content

Commit 879612d

Browse files
committed
feat(commit-input): add multiline feature
- Add ability to the answer inputs to aacept multilines. - No more accidental Enter key, now Enter key only breaks the line into a new line and it can be removed/undo using backspace key normally. - Now the user can submit the commit only when he is sure by pressing combination of Alt + Enter. BREAKING CHANGE:
1 parent 5d24ae2 commit 879612d

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

commitizen/commands/commit.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ def _prompt_commit_questions(self) -> str:
8383
raise CustomError(root_err.__str__())
8484
raise err
8585
elif question["type"] == "input" and question.get("multiline", False):
86-
print(f"\033[90m💡 Multiline input:\n Press Enter for new lines and Esc+Enter to finish\033[0m \n \033[90mor (Finish with 'Alt+Enter' or 'Esc then Enter')\033[0m")
86+
print(
87+
"\033[90m💡 Multiline input:\n Press Enter for new lines and Esc+Enter to finish\033[0m \n \033[90mor (Finish with 'Alt+Enter' or 'Esc then Enter')\033[0m"
88+
)
8789
multiline_question = question.copy()
8890
multiline_question["multiline"] = True
8991
try:

commitizen/cz/conventional_commits/conventional_commits.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from commitizen import defaults
55
from commitizen.cz.base import BaseCommitizen
6-
from commitizen.cz.utils import multiple_line_breaker, required_validator
6+
from commitizen.cz.utils import required_validator
77
from commitizen.question import CzQuestion
88

99
__all__ = ["ConventionalCommitsCz"]

commitizen/cz/utils.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
import re
33
import tempfile
44

5-
import questionary
6-
75
from commitizen import git
86
from commitizen.cz import exceptions
97

@@ -20,8 +18,6 @@ def multiple_line_breaker(answer: str, sep: str = "|") -> str:
2018
return "\n".join(line.strip() for line in answer.split(sep) if line)
2119

2220

23-
24-
2521
def strip_local_version(version: str) -> str:
2622
return _RE_LOCAL_VERSION.sub("", version)
2723

0 commit comments

Comments
 (0)