askrobots / askrobots_commitgen
Public
AI-Powered Git Commit Message Generator
danq9
Create commit message adjusting OpenAI initialization and error handling.
c0d2e25
2 years, 6 months ago
History
git_operations.py · 324 bytes · 10 lines
| 1 | import subprocess |
| 2 | |
| 3 | def get_git_diff() -> str: |
| 4 | try: |
| 5 | # Using --cached to get the diff of staged changes |
| 6 | diff = subprocess.check_output(["git", "diff", "--cached"], text=True) |
| 7 | return diff |
| 8 | except subprocess.CalledProcessError as e: |
| 9 | print(f"Error getting git diff: {e}") |
| 10 | return "" |