MCPcopy
hub / github.com/langroid/langroid / git_restore_file

Function git_restore_file

langroid/utils/git_utils.py:180–196  ·  view source on GitHub ↗

Restore a specific file in the Git repository to its state in the last commit. This function undoes changes to the specified file. Args: repo (git.Repo): The Git repository object file_path (str): Path to the file to be restored Returns: None

(repo: git.Repo, file_path: str)

Source from the content-addressed store, hash-verified

178
179
180def git_restore_file(repo: git.Repo, file_path: str) -> None:
181 """
182 Restore a specific file in the Git repository to its state in the last commit.
183 This function undoes changes to the specified file.
184
185 Args:
186 repo (git.Repo): The Git repository object
187 file_path (str): Path to the file to be restored
188
189 Returns:
190 None
191 """
192 try:
193 repo.git.restore(file_path)
194 logger.info(f"Successfully restored file: {file_path}")
195 except git.GitCommandError as e:
196 logger.error(f"An error occurred while restoring file {file_path}: {e}")
197
198
199def git_create_checkout_branch(repo: git.Repo, branch: str) -> None:

Callers 1

test_git_restore_fileFunction · 0.90

Calls 1

infoMethod · 0.80

Tested by 1

test_git_restore_fileFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…