Skip to content

Commit 1d95164

Browse files
committed
Ensure branch is fetched
1 parent 26533ef commit 1d95164

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/commands/fix/git.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { PackageURL } from '@socketregistry/packageurl-js'
2+
import { debugLog } from '@socketsecurity/registry/lib/debug'
23
import { logger } from '@socketsecurity/registry/lib/logger'
34
import { spawn } from '@socketsecurity/registry/lib/spawn'
45

@@ -37,11 +38,13 @@ export async function checkoutBaseBranchIfAvailable(
3738
cwd: string | undefined = process.cwd()
3839
) {
3940
try {
41+
await spawn('git', ['fetch', '--depth=1', 'origin', baseBranch], { cwd })
4042
await spawn('git', ['checkout', baseBranch], { cwd })
4143
await spawn('git', ['reset', '--hard', `origin/${baseBranch}`], { cwd })
4244
logger.info(`Checked out and reset to ${baseBranch}`)
43-
} catch {
45+
} catch (e) {
4446
logger.warn(`Could not switch to ${baseBranch}. Proceeding with HEAD.`)
47+
debugLog(e)
4548
}
4649
}
4750

0 commit comments

Comments
 (0)