-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
642329a
commit 83aa474
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import wx | ||
import subprocess | ||
import main | ||
|
||
def commit(): | ||
try: | ||
# Create text entry dialog to get commit message | ||
with wx.TextEntryDialog(None, "Enter Commit Message", "Git Commit") as msg_dialog: | ||
if msg_dialog.ShowModal() == wx.ID_OK: | ||
msg = msg_dialog.GetValue().strip() | ||
|
||
# Validate commit message | ||
if not msg: | ||
wx.MessageBox("Commit message cannot be empty", "Error", wx.OK | wx.ICON_ERROR) | ||
return | ||
|
||
try: | ||
# Use subprocess for safer command execution | ||
subprocess.run(['git', 'add', '.'], check=True) | ||
subprocess.run(['git', 'commit', '-m', msg], check=True) | ||
wx.MessageBox("Commit successful!", "Success", wx.OK | wx.ICON_INFORMATION) | ||
|
||
except subprocess.CalledProcessError as e: | ||
wx.MessageBox(f"Git commit failed: {e}", "Error", wx.OK | wx.ICON_ERROR) | ||
|
||
except Exception as e: | ||
wx.MessageBox(f"An error occurred: {e}", "Error", wx.OK | wx.ICON_ERROR) |