MCPcopy Index your code
hub / github.com/huggingface/diffusers / checkout_commit

Function checkout_commit

utils/tests_fetcher.py:88–103  ·  view source on GitHub ↗

Context manager that checks out a given commit when entered, but gets back to the reference it was at on exit. Args: repo (`git.Repo`): A git repository (for instance the Transformers repo). commit_id (`str`): The commit reference to checkout inside the context manager.

(repo: Repo, commit_id: str)

Source from the content-addressed store, hash-verified

86
87@contextmanager
88def checkout_commit(repo: Repo, commit_id: str):
89 """
90 Context manager that checks out a given commit when entered, but gets back to the reference it was at on exit.
91
92 Args:
93 repo (`git.Repo`): A git repository (for instance the Transformers repo).
94 commit_id (`str`): The commit reference to checkout inside the context manager.
95 """
96 current_head = repo.head.commit if repo.head.is_detached else repo.head.ref
97
98 try:
99 repo.git.checkout(commit_id)
100 yield
101
102 finally:
103 repo.git.checkout(current_head)
104
105
106def clean_code(content: str) -> str:

Callers 3

diff_is_docstring_onlyFunction · 0.85
get_new_doctest_filesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…