-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into bump-dugite-native
- Loading branch information
Showing
5 changed files
with
82 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,31 @@ | ||
import { dirname } from 'path' | ||
import { default as findGit, Git } from 'find-git-exec' | ||
import { resolve } from 'path' | ||
import findGit from 'find-git-exec' | ||
|
||
import { GitProcess } from '../../lib' | ||
import { verify } from '../helpers' | ||
|
||
const temp = require('temp').track() | ||
|
||
async function setupGitEnvironment(): Promise<Git | null> { | ||
let git: Git | undefined = undefined | ||
|
||
try { | ||
git = await findGit() | ||
} catch { | ||
return null | ||
} | ||
if (!git || !git.path || !git.execPath) { | ||
return null | ||
} else { | ||
const { path, execPath } = git | ||
// Set the environment variable to be able to use an external Git. | ||
process.env.GIT_EXEC_PATH = execPath | ||
process.env.LOCAL_GIT_DIRECTORY = dirname(dirname(path)) | ||
return git | ||
} | ||
} | ||
const getExternalGitEnvironment = () => | ||
findGit().then(({ path, execPath }) => ({ | ||
GIT_EXEC_PATH: execPath, | ||
LOCAL_GIT_DIRECTORY: resolve(path, '../../'), | ||
})) | ||
|
||
describe('git-process [with external Git executable]', () => { | ||
describe('clone', () => { | ||
describe('--exec-path', () => { | ||
it('returns exit code when successful', async () => { | ||
const git = await setupGitEnvironment() | ||
if (git == null) { | ||
throw new Error('External Git was not found on the host system.') | ||
} | ||
const env = await getExternalGitEnvironment() | ||
|
||
const testRepoPath = temp.mkdirSync('desktop-git-clone-valid-external') | ||
const result = await GitProcess.exec( | ||
['clone', '--', 'https://github.com/TypeFox/find-git-exec.git', '.'], | ||
testRepoPath | ||
) | ||
verify(result, r => { | ||
expect(r.exitCode).toEqual(0) | ||
const result = await GitProcess.exec(['--exec-path'], testRepoPath, { | ||
env, | ||
}) | ||
|
||
verify(result, r => expect(r.exitCode).toEqual(0)) | ||
verify(result, r => | ||
expect(resolve(r.stdout.trim())).toEqual(resolve(env.GIT_EXEC_PATH)) | ||
) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters