MCPcopy
hub / github.com/langroid/langroid / git_commit_mods

Function git_commit_mods

langroid/utils/git_utils.py:137–156  ·  view source on GitHub ↗

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")

Source from the content-addressed store, hash-verified

135
136
137def 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
159def git_restore_repo(repo: git.Repo) -> None:

Callers 1

test_git_commit_modsFunction · 0.90

Calls 2

infoMethod · 0.80
addMethod · 0.45

Tested by 1

test_git_commit_modsFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…