MCPcopy
hub / github.com/coderamp-labs/gitingest / resolve_commit

Function resolve_commit

src/gitingest/utils/git_utils.py:350–374  ·  view source on GitHub ↗

Resolve the commit to use for the clone. Parameters ---------- config : CloneConfig The configuration for cloning the repository. token : str | None GitHub personal access token (PAT) for accessing private repositories. Returns ------- str The co

(config: CloneConfig, token: str | None)

Source from the content-addressed store, hash-verified

348
349
350async def resolve_commit(config: CloneConfig, token: str | None) -> str:
351 """Resolve the commit to use for the clone.
352
353 Parameters
354 ----------
355 config : CloneConfig
356 The configuration for cloning the repository.
357 token : str | None
358 GitHub personal access token (PAT) for accessing private repositories.
359
360 Returns
361 -------
362 str
363 The commit SHA.
364
365 """
366 if config.commit:
367 commit = config.commit
368 elif config.tag:
369 commit = await _resolve_ref_to_sha(config.url, pattern=f"refs/tags/{config.tag}*", token=token)
370 elif config.branch:
371 commit = await _resolve_ref_to_sha(config.url, pattern=f"refs/heads/{config.branch}", token=token)
372 else:
373 commit = await _resolve_ref_to_sha(config.url, pattern="HEAD", token=token)
374 return commit
375
376
377async def _resolve_ref_to_sha(url: str, pattern: str, token: str | None = None) -> str:

Callers 3

parse_remote_repoFunction · 0.90
clone_repoFunction · 0.90
_check_s3_cacheFunction · 0.90

Calls 1

_resolve_ref_to_shaFunction · 0.85

Tested by

no test coverage detected