MCPcopy Index your code
hub / github.com/sourcebot-dev/sourcebot / getCommitHashForRefName

Function getCommitHashForRefName

packages/backend/src/git.ts:345–365  ·  view source on GitHub ↗
({
    path,
    refName,
}: {
    path: string,
    refName: string,
})

Source from the content-addressed store, hash-verified

343};
344
345export const getCommitHashForRefName = async ({
346 path,
347 refName,
348}: {
349 path: string,
350 refName: string,
351}) => {
352 const git = createGitClientForPath(path);
353
354 try {
355 // The `^{commit}` suffix is used to fully dereference the ref to a commit hash.
356 const rev = await git.revparse(`${refName}^{commit}`);
357 return rev;
358
359 // @note: Was hitting errors when the repository is empty,
360 // so we're catching the error and returning undefined.
361 } catch (error: unknown) {
362 logger.debug(error);
363 return undefined;
364 }
365}
366
367/**
368 * Gets the default branch name from the remote repository by querying what

Callers 1

onJobCompletedMethod · 0.85

Calls 1

createGitClientForPathFunction · 0.85

Tested by

no test coverage detected