Skip to content

Commit f5458c4

Browse files
wip
1 parent de621d6 commit f5458c4

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

packages/backend/src/git.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import { env } from "@sourcebot/shared";
1+
import { env, createLogger } from "@sourcebot/shared";
22
import { existsSync } from 'node:fs';
33
import { mkdir } from 'node:fs/promises';
44
import { dirname, resolve } from 'node:path';
55
import { CheckRepoActions, GitConfigScope, simpleGit, SimpleGitProgressEvent } from 'simple-git';
66

77
type onProgressFn = (event: SimpleGitProgressEvent) => void;
88

9+
const logger = createLogger('git-utils');
10+
911
/**
1012
* Creates a simple-git client that has it's working directory
1113
* set to the given path.
@@ -288,7 +290,11 @@ export const getCommitHashForRefName = async ({
288290
// The `^{commit}` suffix is used to fully dereference the ref to a commit hash.
289291
const rev = await git.revparse(`${refName}^{commit}`);
290292
return rev;
293+
294+
// @note: Was hitting errors when the repository is empty,
295+
// so we're catching the error and returning undefined.
291296
} catch (error: unknown) {
297+
logger.debug(error);
292298
return undefined;
293299
}
294300
}

0 commit comments

Comments
 (0)