Skip to content

Commit facffb8

Browse files
committed
Fix tests and variable shadowing bug in withGit helper
1 parent 4a88db8 commit facffb8

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

packages/cli-kit/src/public/node/git.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ describe('initializeRepository()', () => {
252252

253253
// Then
254254
expect(simpleGit).toHaveBeenCalledOnce()
255-
expect(simpleGit).toHaveBeenCalledWith('/tmp/git-repo')
255+
expect(simpleGit).toHaveBeenCalledWith({baseDir: '/tmp/git-repo'})
256256

257257
expect(mockedInit).toHaveBeenCalledOnce()
258258
expect(mockedCheckout).toHaveBeenCalledOnce()
@@ -617,7 +617,7 @@ describe('removeGitRemote()', () => {
617617
await git.removeGitRemote(directory, remoteName)
618618

619619
// Then
620-
expect(simpleGit).toHaveBeenCalledWith(directory)
620+
expect(simpleGit).toHaveBeenCalledWith({baseDir: directory})
621621
expect(mockedGetRemotes).toHaveBeenCalled()
622622
expect(mockedRemoveRemote).toHaveBeenCalledWith(remoteName)
623623
})
@@ -635,7 +635,7 @@ describe('removeGitRemote()', () => {
635635
await git.removeGitRemote(directory, remoteName)
636636

637637
// Then
638-
expect(simpleGit).toHaveBeenCalledWith(directory)
638+
expect(simpleGit).toHaveBeenCalledWith({baseDir: directory})
639639
expect(mockedGetRemotes).toHaveBeenCalled()
640640
expect(mockedRemoveRemote).not.toHaveBeenCalled()
641641
})

packages/cli-kit/src/public/node/git.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,9 +381,9 @@ async function withGit<T>({
381381
}): Promise<T> {
382382
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
383383
// @ts-ignore
384-
const git = git({baseDir: directory})
384+
const repo = git({baseDir: directory})
385385
try {
386-
return await callback(git)
386+
return await callback(repo)
387387
} catch (err) {
388388
if (err instanceof Error) {
389389
const abortError = new AbortError(err.message)

0 commit comments

Comments
 (0)