Commit all modifications in the Git repository. Does not raise an error if there's nothing to commit. Args: repo (git.Repo): The Git repository object Returns: None
(repo: git.Repo, msg: str = "commit all changes")
| 135 | |
| 136 | |
| 137 | def git_commit_mods(repo: git.Repo, msg: str = "commit all changes") -> None: |
| 138 | """ |
| 139 | Commit all modifications in the Git repository. |
| 140 | Does not raise an error if there's nothing to commit. |
| 141 | |
| 142 | Args: |
| 143 | repo (git.Repo): The Git repository object |
| 144 | |
| 145 | Returns: |
| 146 | None |
| 147 | """ |
| 148 | try: |
| 149 | if repo.is_dirty(): |
| 150 | repo.git.add(update=True) |
| 151 | repo.index.commit(msg) |
| 152 | logger.info("Successfully committed all modifications") |
| 153 | else: |
| 154 | logger.info("No changes to commit") |
| 155 | except git.GitCommandError as e: |
| 156 | logger.error(f"An error occurred while committing modifications: {e}") |
| 157 | |
| 158 | |
| 159 | def git_restore_repo(repo: git.Repo) -> None: |
searching dependent graphs…