Skip to content

Commit

Permalink
Handle non existing git repo (#425)
Browse files Browse the repository at this point in the history
* Handle non existing git repo

* Add changeset
  • Loading branch information
nichochar authored Oct 25, 2024
1 parent 4a57f62 commit e361ea8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .changeset/smart-elephants-fly.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@srcbook/api': patch
'srcbook': patch
---

Bugfix: dont crash if the git repo didnt previously exist
7 changes: 7 additions & 0 deletions packages/api/apps/git.mts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,14 @@ export async function ensureRepoExists(app: DBAppType): Promise<void> {
// Get the current commit SHA
export async function getCurrentCommitSha(app: DBAppType): Promise<string> {
const git = getGit(app);
// There might not be a .git initialized yet, so we need to handle that
const isRepo = await git.checkIsRepo();
if (!isRepo) {
await initRepo(app);
}

const revparse = await git.revparse(['HEAD']);

return revparse;
}

Expand Down

0 comments on commit e361ea8

Please sign in to comment.