Commit a file to a Git repository. Args: repo (git.Repo): The Git repository object filepath (str): Path to the file to be committed msg (str): The commit message Returns: None
(repo: git.Repo, filepath: str, msg: str)
| 114 | |
| 115 | |
| 116 | def git_commit_file(repo: git.Repo, filepath: str, msg: str) -> None: |
| 117 | """ |
| 118 | Commit a file to a Git repository. |
| 119 | |
| 120 | Args: |
| 121 | repo (git.Repo): The Git repository object |
| 122 | filepath (str): Path to the file to be committed |
| 123 | msg (str): The commit message |
| 124 | |
| 125 | Returns: |
| 126 | None |
| 127 | """ |
| 128 | try: |
| 129 | repo.index.add([filepath]) |
| 130 | commit_msg = msg or f"Updated {filepath}" |
| 131 | repo.index.commit(commit_msg) |
| 132 | logger.info(f"Successfully committed {filepath}: {commit_msg}") |
| 133 | except git.GitCommandError as e: |
| 134 | logger.error(f"An error occurred while committing: {e}") |
| 135 | |
| 136 | |
| 137 | def git_commit_mods(repo: git.Repo, msg: str = "commit all changes") -> None: |
searching dependent graphs…