refactor: move git operations into seperate files

This commit is contained in:
Sam Chau
2024-09-03 20:17:40 +09:30
parent 623f510ff9
commit ec7430466f
8 changed files with 208 additions and 120 deletions

View File

@@ -0,0 +1,16 @@
# git/operations/commit.py
import git
import logging
logger = logging.getLogger(__name__)
def commit_changes(repo_path, files, message):
try:
repo = git.Repo(repo_path)
repo.index.add(files)
repo.index.commit(message)
return True, "Successfully committed changes."
except Exception as e:
logger.error(f"Error committing changes: {str(e)}", exc_info=True)
return False, f"Error committing changes: {str(e)}"