Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

refactor: misc cleanup #1428

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 7 additions & 14 deletions commitizen/cz/conventional_commits/conventional_commits.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class ConventionalCommitsCz(BaseCommitizen):
changelog_pattern = defaults.bump_pattern

def questions(self) -> Questions:
questions: Questions = [
return [
{
"type": "list",
"name": "prefix",
Expand Down Expand Up @@ -146,7 +146,6 @@ def questions(self) -> Questions:
),
},
]
return questions

def message(self, answers: dict) -> str:
prefix = answers["prefix"]
Expand All @@ -165,9 +164,7 @@ def message(self, answers: dict) -> str:
if footer:
footer = f"\n\n{footer}"

message = f"{prefix}{scope}: {subject}{body}{footer}"

return message
return f"{prefix}{scope}: {subject}{body}{footer}"

def example(self) -> str:
return (
Expand All @@ -188,25 +185,21 @@ def schema(self) -> str:
)

def schema_pattern(self) -> str:
PATTERN = (
return (
r"(?s)" # To explicitly make . match new line
r"(build|ci|docs|feat|fix|perf|refactor|style|test|chore|revert|bump)" # type
r"(\(\S+\))?!?:" # scope
r"( [^\n\r]+)" # subject
r"((\n\n.*)|(\s*))?$"
)
return PATTERN

def info(self) -> str:
dir_path = os.path.dirname(os.path.realpath(__file__))
filepath = os.path.join(dir_path, "conventional_commits_info.txt")
with open(filepath, encoding=self.config.settings["encoding"]) as f:
content = f.read()
return content
return f.read()

def process_commit(self, commit: str) -> str:
pat = re.compile(self.schema_pattern())
m = re.match(pat, commit)
if m is None:
return ""
return m.group(3).strip()
if m := re.match(self.schema_pattern(), commit):
return m.group(3).strip()
return ""
6 changes: 2 additions & 4 deletions commitizen/cz/jira/jira.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class JiraSmartCz(BaseCommitizen):
def questions(self) -> Questions:
questions = [
return [
{
"type": "input",
"name": "message",
Expand Down Expand Up @@ -42,7 +42,6 @@ def questions(self) -> Questions:
"filter": lambda x: "#comment " + x if x else "",
},
]
return questions

def message(self, answers: dict) -> str:
return " ".join(
Expand Down Expand Up @@ -77,5 +76,4 @@ def info(self) -> str:
dir_path = os.path.dirname(os.path.realpath(__file__))
filepath = os.path.join(dir_path, "jira_info.txt")
with open(filepath, encoding=self.config.settings["encoding"]) as f:
content = f.read()
return content
return f.read()