Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fe16989

Browse filesBrowse files
committed
refactor(git): extract _get_commit_command
1 parent 8d57306 commit fe16989
Copy full SHA for fe16989

File tree

1 file changed

+11
-8
lines changed
Filter options

1 file changed

+11
-8
lines changed

‎commitizen/git.py

Copy file name to clipboardExpand all lines: commitizen/git.py
+11-8Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,19 +119,22 @@ def commit(
119119
f.write(message.encode("utf-8"))
120120
f.close()
121121

122-
command = f'git commit {args} -F "{f.name}"'
123-
124-
if committer_date and os.name == "nt": # pragma: no cover
125-
# Using `cmd /v /c "{command}"` sets environment variables only for that command
126-
command = f'cmd /v /c "set GIT_COMMITTER_DATE={committer_date}&& {command}"'
127-
elif committer_date:
128-
command = f"GIT_COMMITTER_DATE={committer_date} {command}"
129-
122+
command = _get_commit_command(args, committer_date, f.name)
130123
c = cmd.run(command)
131124
os.unlink(f.name)
132125
return c
133126

134127

128+
def _get_commit_command(args: str, committer_date: str | None, name: str) -> str:
129+
command = f'git commit {args} -F "{name}"'
130+
if not committer_date:
131+
return command
132+
if os.name != "nt":
133+
return f"GIT_COMMITTER_DATE={committer_date} {command}"
134+
# Using `cmd /v /c "{command}"` sets environment variables only for that command
135+
return f'cmd /v /c "set GIT_COMMITTER_DATE={committer_date}&& {command}"'
136+
137+
135138
def get_commits(
136139
start: str | None = None,
137140
end: str = "HEAD",

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.