Skip to content

Commit 5015ad6

Browse files
committed
fix: simplify message extraction in generate_commit_message
Refactor the message handling logic to remove the need for splitting and checking for specific markers. The new implementation directly replaces the markers, streamlining the extraction process.
1 parent 73d7128 commit 5015ad6

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

main.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,7 @@ def generate_commit_message(diff) -> str:
6464
return ""
6565

6666
message = message.strip()
67-
68-
if "```gitcommit" in message and "```" in message.split("```gitcommit", 1)[1]:
69-
message = message.split("```gitcommit", 1)[1].split("```", 1)[0].strip()
67+
message = message.replace("```gitcommit", "").replace("```", "").strip()
7068

7169
return message
7270
except Exception as e:
@@ -76,8 +74,12 @@ def generate_commit_message(diff) -> str:
7674

7775
def commit_and_push(commit_message):
7876
try:
79-
subprocess.run(["git", "commit", "-m", commit_message], check=True)
80-
print(f"Committed with message:\n{commit_message}")
77+
subprocess.run(
78+
["git", "commit", "-m", commit_message],
79+
check=True,
80+
stdout=subprocess.DEVNULL,
81+
)
82+
print(commit_message)
8183

8284
push = input("Push changes to remote? (y/n): ").lower()
8385
if push == "y":

0 commit comments

Comments
 (0)