MCPcopy
hub / github.com/langroid/langroid / git_commit_file

Function git_commit_file

langroid/utils/git_utils.py:116–134  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

114
115
116def 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
137def git_commit_mods(repo: git.Repo, msg: str = "commit all changes") -> None:

Callers 4

handleMethod · 0.90
test_git_commit_fileFunction · 0.90
test_git_restore_fileFunction · 0.90
test_git_diff_fileFunction · 0.90

Calls 2

infoMethod · 0.80
addMethod · 0.45

Tested by 3

test_git_commit_fileFunction · 0.72
test_git_restore_fileFunction · 0.72
test_git_diff_fileFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…