MCPcopy Index your code
hub / github.com/Codeplain-ai/codeplain / checkout_commit_with_frid

Function checkout_commit_with_frid

git_utils.py:169–187  ·  view source on GitHub ↗

Finds commit with given frid mentioned in the commit message and checks out that commit. If frid argument is not provided (None), repo is checked out to the initial state. In case the base folder doesn't exist, code is checked out to the initial repo commit. Otherwise, the repo is chec

(repo_path: Union[str, os.PathLike], frid: Optional[str] = None)

Source from the content-addressed store, hash-verified

167
168
169def checkout_commit_with_frid(repo_path: Union[str, os.PathLike], frid: Optional[str] = None) -> Repo:
170 """
171 Finds commit with given frid mentioned in the commit message and checks out that commit.
172
173 If frid argument is not provided (None), repo is checked out to the initial state. In case the base folder doesn't exist,
174 code is checked out to the initial repo commit. Otherwise, the repo is checked out to the base folder commit.
175
176 It is expected that the repo has at least one commit related to provided frid if frid is not None.
177 In case the frid related commit is not found, an exception is raised.
178 """
179 repo = Repo(repo_path)
180
181 commit = _get_commit(repo, frid)
182
183 if not commit:
184 raise InvalidGitRepositoryError("Git repository is in an invalid state. Relevant commit could not be found.")
185
186 repo.git.checkout(commit)
187 return repo
188
189
190def checkout_previous_branch(repo_path: Union[str, os.PathLike]) -> Repo:

Callers

nothing calls this directly

Calls 2

_get_commitFunction · 0.85

Tested by

no test coverage detected