File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change 11import { execFileSync } from 'child_process'
22import fs , { existsSync , statSync } from 'fs'
33import gitUrlParse from 'git-url-parse'
4- import { getConfig , listFiles , log } from 'isomorphic-git'
4+ import { getConfig , listFiles , log , ReadCommitResult } from 'isomorphic-git'
55import path from 'path'
66import { getWorkingDirectory } from '../project-files'
77import { logger } from './logger'
@@ -78,7 +78,15 @@ export async function getRepoMetrics(providedRemoteUrl?: string): Promise<{
7878
7979 const gitDir = path . join ( root , '.git' )
8080
81- const commitsArr = await log ( { fs, dir : root , gitdir : gitDir } )
81+ const commitsArr = await log ( { fs, dir : root , gitdir : gitDir } ) . catch (
82+ ( error ) => {
83+ logger . error (
84+ { error } ,
85+ 'Error fetching git log. Is this an empty git repo?'
86+ )
87+ return [ ] as ReadCommitResult [ ]
88+ }
89+ )
8290 const firstCommit = commitsArr . at ( - 1 ) // earliest
8391
8492 const tracked = await listFiles ( { fs, dir : root , gitdir : gitDir } )
You can’t perform that action at this time.
0 commit comments