mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 02:58:56 +01:00
ref #44776 Cater for the cases of multiple/no previous hashes
This commit is contained in:
@@ -178,22 +178,46 @@ suite('git', () => {
|
||||
});
|
||||
|
||||
suite('Repository', () => {
|
||||
test('get commit', async () => {
|
||||
const spawnOption = {};
|
||||
const gitOutput = `52c293a05038d865604c2284aa8698bd087915a1
|
||||
const spawnOption = {};
|
||||
const GIT_OUTPUT_SINGLE_PARENT = `52c293a05038d865604c2284aa8698bd087915a1
|
||||
8e5a374372b8393906c7e380dbb09349c5385554
|
||||
This is a commit message.`;
|
||||
const git = sinon.createStubInstance(Git);
|
||||
git.exec = sinon.stub()
|
||||
.withArgs('REPOSITORY_ROOT', ['show', '-s', '--format=%H\n%P\n%B', 'REF_SINGLE_PARENT'], spawnOption)
|
||||
.returns(Promise.resolve({stdout: gitOutput}));
|
||||
const repository = new Repository(git, 'REPOSITORY_ROOT');
|
||||
const GIT_OUTPUT_MULTIPLE_PARENTS = `52c293a05038d865604c2284aa8698bd087915a1
|
||||
8e5a374372b8393906c7e380dbb09349c5385554 df27d8c75b129ab9b178b386077da2822101b217
|
||||
This is a commit message.`;
|
||||
const GIT_OUTPUT_NO_PARENTS = `52c293a05038d865604c2284aa8698bd087915a1
|
||||
|
||||
This is a commit message.`;
|
||||
|
||||
const git = sinon.createStubInstance(Git);
|
||||
git.exec = sinon.stub();
|
||||
git.exec
|
||||
.withArgs('REPOSITORY_ROOT', ['show', '-s', '--format=%H\n%P\n%B', 'REF_SINGLE_PARENT'], spawnOption)
|
||||
.returns(Promise.resolve({stdout: GIT_OUTPUT_SINGLE_PARENT}));
|
||||
git.exec
|
||||
.withArgs('REPOSITORY_ROOT', ['show', '-s', '--format=%H\n%P\n%B', 'REF_MULTIPLE_PARENTS'], spawnOption)
|
||||
.returns(Promise.resolve({stdout: GIT_OUTPUT_MULTIPLE_PARENTS}));
|
||||
git.exec
|
||||
.withArgs('REPOSITORY_ROOT', ['show', '-s', '--format=%H\n%P\n%B', 'REF_NO_PARENTS'], spawnOption)
|
||||
.returns(Promise.resolve({stdout: GIT_OUTPUT_NO_PARENTS}));
|
||||
const repository = new Repository(git, 'REPOSITORY_ROOT');
|
||||
|
||||
test('get commit', async () => {
|
||||
assert.deepEqual(await repository.getCommit('REF_SINGLE_PARENT'), {
|
||||
hash: '52c293a05038d865604c2284aa8698bd087915a1',
|
||||
message: 'This is a commit message.',
|
||||
previousHashes: ['8e5a374372b8393906c7e380dbb09349c5385554']
|
||||
});
|
||||
});
|
||||
|
||||
test('multiple previous commits', async () => {
|
||||
const commit = await repository.getCommit('REF_MULTIPLE_PARENTS');
|
||||
assert.deepEqual(commit.previousHashes, ['8e5a374372b8393906c7e380dbb09349c5385554', 'df27d8c75b129ab9b178b386077da2822101b217']);
|
||||
});
|
||||
|
||||
test('no previous commits', async () => {
|
||||
const commit = await repository.getCommit('REF_NO_PARENTS');
|
||||
assert.deepEqual(commit.previousHashes, []);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user