|
|
@ -2,6 +2,7 @@ import * as assert from 'assert'; |
|
|
|
import { basename } from 'path'; |
|
|
|
import { Uri } from 'vscode'; |
|
|
|
import { isLinux } from '../../../env/node/platform'; |
|
|
|
import { normalizeRepoUri } from '../../../repositories'; |
|
|
|
import { PathEntryTrie, UriEntry, UriEntryTrie, UriTrie } from '../../../system/trie'; |
|
|
|
// eslint-disable-next-line import/extensions
|
|
|
|
import paths from './paths.json'; |
|
|
@ -442,102 +443,102 @@ describe('UriEntryTrie Test Suite', () => { |
|
|
|
); |
|
|
|
}); |
|
|
|
|
|
|
|
it('has(gitlens://): repo', () => { |
|
|
|
assert.strictEqual( |
|
|
|
trie.has( |
|
|
|
repoGL.uri.with({ |
|
|
|
scheme: 'gitlens', |
|
|
|
authority: 'abcd', |
|
|
|
query: JSON.stringify({ ref: '1234567890' }), |
|
|
|
}), |
|
|
|
), |
|
|
|
true, |
|
|
|
); |
|
|
|
assert.strictEqual( |
|
|
|
trie.has( |
|
|
|
Uri.parse( |
|
|
|
repoGL.uri |
|
|
|
.with({ |
|
|
|
scheme: 'gitlens', |
|
|
|
authority: 'abcd', |
|
|
|
query: JSON.stringify({ ref: '1234567890' }), |
|
|
|
}) |
|
|
|
.toString() |
|
|
|
.toUpperCase(), |
|
|
|
), |
|
|
|
), |
|
|
|
!isLinux, |
|
|
|
); |
|
|
|
assert.strictEqual( |
|
|
|
trie.has( |
|
|
|
repoNested.uri.with({ |
|
|
|
scheme: 'gitlens', |
|
|
|
authority: 'abcd', |
|
|
|
query: JSON.stringify({ ref: '1234567890' }), |
|
|
|
}), |
|
|
|
), |
|
|
|
true, |
|
|
|
); |
|
|
|
assert.strictEqual( |
|
|
|
trie.has( |
|
|
|
Uri.parse( |
|
|
|
repoNested.uri |
|
|
|
.with({ |
|
|
|
scheme: 'gitlens', |
|
|
|
authority: 'abcd', |
|
|
|
query: JSON.stringify({ ref: '1234567890' }), |
|
|
|
}) |
|
|
|
.toString() |
|
|
|
.toUpperCase(), |
|
|
|
), |
|
|
|
), |
|
|
|
!isLinux, |
|
|
|
); |
|
|
|
|
|
|
|
assert.strictEqual( |
|
|
|
trie.has( |
|
|
|
Uri.file('C:\\Users\\Name\\code\\company\\repo').with({ |
|
|
|
scheme: 'gitlens', |
|
|
|
authority: 'abcd', |
|
|
|
query: JSON.stringify({ ref: '1234567890' }), |
|
|
|
}), |
|
|
|
), |
|
|
|
false, |
|
|
|
); |
|
|
|
}); |
|
|
|
|
|
|
|
it('has(gitlens://): file', () => { |
|
|
|
assert.strictEqual( |
|
|
|
trie.has( |
|
|
|
Uri.joinPath(repoGL.uri, 'src/extension.ts').with({ |
|
|
|
scheme: 'gitlens', |
|
|
|
authority: 'abcd', |
|
|
|
query: JSON.stringify({ ref: '1234567890' }), |
|
|
|
}), |
|
|
|
), |
|
|
|
true, |
|
|
|
); |
|
|
|
assert.strictEqual( |
|
|
|
trie.has( |
|
|
|
Uri.joinPath(repoGL.uri, 'foo/bar/baz.ts').with({ |
|
|
|
scheme: 'gitlens', |
|
|
|
authority: 'abcd', |
|
|
|
query: JSON.stringify({ ref: '1234567890' }), |
|
|
|
}), |
|
|
|
), |
|
|
|
false, |
|
|
|
); |
|
|
|
assert.strictEqual( |
|
|
|
trie.has( |
|
|
|
Uri.joinPath(repoNested.uri, 'src/index.ts').with({ |
|
|
|
scheme: 'gitlens', |
|
|
|
authority: 'abcd', |
|
|
|
query: JSON.stringify({ ref: '1234567890' }), |
|
|
|
}), |
|
|
|
), |
|
|
|
true, |
|
|
|
); |
|
|
|
}); |
|
|
|
// it('has(gitlens://): repo', () => {
|
|
|
|
// assert.strictEqual(
|
|
|
|
// trie.has(
|
|
|
|
// repoGL.uri.with({
|
|
|
|
// scheme: 'gitlens',
|
|
|
|
// authority: 'abcd',
|
|
|
|
// query: JSON.stringify({ ref: '1234567890' }),
|
|
|
|
// }),
|
|
|
|
// ),
|
|
|
|
// true,
|
|
|
|
// );
|
|
|
|
// assert.strictEqual(
|
|
|
|
// trie.has(
|
|
|
|
// Uri.parse(
|
|
|
|
// repoGL.uri
|
|
|
|
// .with({
|
|
|
|
// scheme: 'gitlens',
|
|
|
|
// authority: 'abcd',
|
|
|
|
// query: JSON.stringify({ ref: '1234567890' }),
|
|
|
|
// })
|
|
|
|
// .toString()
|
|
|
|
// .toUpperCase(),
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// !isLinux,
|
|
|
|
// );
|
|
|
|
// assert.strictEqual(
|
|
|
|
// trie.has(
|
|
|
|
// repoNested.uri.with({
|
|
|
|
// scheme: 'gitlens',
|
|
|
|
// authority: 'abcd',
|
|
|
|
// query: JSON.stringify({ ref: '1234567890' }),
|
|
|
|
// }),
|
|
|
|
// ),
|
|
|
|
// true,
|
|
|
|
// );
|
|
|
|
// assert.strictEqual(
|
|
|
|
// trie.has(
|
|
|
|
// Uri.parse(
|
|
|
|
// repoNested.uri
|
|
|
|
// .with({
|
|
|
|
// scheme: 'gitlens',
|
|
|
|
// authority: 'abcd',
|
|
|
|
// query: JSON.stringify({ ref: '1234567890' }),
|
|
|
|
// })
|
|
|
|
// .toString()
|
|
|
|
// .toUpperCase(),
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// !isLinux,
|
|
|
|
// );
|
|
|
|
|
|
|
|
// assert.strictEqual(
|
|
|
|
// trie.has(
|
|
|
|
// Uri.file('C:\\Users\\Name\\code\\company\\repo').with({
|
|
|
|
// scheme: 'gitlens',
|
|
|
|
// authority: 'abcd',
|
|
|
|
// query: JSON.stringify({ ref: '1234567890' }),
|
|
|
|
// }),
|
|
|
|
// ),
|
|
|
|
// false,
|
|
|
|
// );
|
|
|
|
// });
|
|
|
|
|
|
|
|
// it('has(gitlens://): file', () => {
|
|
|
|
// assert.strictEqual(
|
|
|
|
// trie.has(
|
|
|
|
// Uri.joinPath(repoGL.uri, 'src/extension.ts').with({
|
|
|
|
// scheme: 'gitlens',
|
|
|
|
// authority: 'abcd',
|
|
|
|
// query: JSON.stringify({ ref: '1234567890' }),
|
|
|
|
// }),
|
|
|
|
// ),
|
|
|
|
// true,
|
|
|
|
// );
|
|
|
|
// assert.strictEqual(
|
|
|
|
// trie.has(
|
|
|
|
// Uri.joinPath(repoGL.uri, 'foo/bar/baz.ts').with({
|
|
|
|
// scheme: 'gitlens',
|
|
|
|
// authority: 'abcd',
|
|
|
|
// query: JSON.stringify({ ref: '1234567890' }),
|
|
|
|
// }),
|
|
|
|
// ),
|
|
|
|
// false,
|
|
|
|
// );
|
|
|
|
// assert.strictEqual(
|
|
|
|
// trie.has(
|
|
|
|
// Uri.joinPath(repoNested.uri, 'src/index.ts').with({
|
|
|
|
// scheme: 'gitlens',
|
|
|
|
// authority: 'abcd',
|
|
|
|
// query: JSON.stringify({ ref: '1234567890' }),
|
|
|
|
// }),
|
|
|
|
// ),
|
|
|
|
// true,
|
|
|
|
// );
|
|
|
|
// });
|
|
|
|
|
|
|
|
it('get(file://): repo', () => { |
|
|
|
assertRepoEntry(trie.get(repoGL.uri), repoGL); |
|
|
@ -560,29 +561,29 @@ describe('UriEntryTrie Test Suite', () => { |
|
|
|
assertRepoEntry(trie.get(repoVSCvfs.uri.with({ scheme: 'github' })), repoVSCvfs); |
|
|
|
}); |
|
|
|
|
|
|
|
it('get(gitlens://): repo', () => { |
|
|
|
assertRepoEntry( |
|
|
|
trie.get( |
|
|
|
repoGL.uri.with({ |
|
|
|
scheme: 'gitlens', |
|
|
|
authority: 'abcd', |
|
|
|
query: JSON.stringify({ ref: '1234567890' }), |
|
|
|
}), |
|
|
|
), |
|
|
|
repoGL, |
|
|
|
); |
|
|
|
|
|
|
|
assertRepoEntry( |
|
|
|
trie.get( |
|
|
|
repoNested.uri.with({ |
|
|
|
scheme: 'gitlens', |
|
|
|
authority: 'abcd', |
|
|
|
query: JSON.stringify({ ref: '1234567890' }), |
|
|
|
}), |
|
|
|
), |
|
|
|
repoNested, |
|
|
|
); |
|
|
|
}); |
|
|
|
// it('get(gitlens://): repo', () => {
|
|
|
|
// assertRepoEntry(
|
|
|
|
// trie.get(
|
|
|
|
// repoGL.uri.with({
|
|
|
|
// scheme: 'gitlens',
|
|
|
|
// authority: 'abcd',
|
|
|
|
// query: JSON.stringify({ ref: '1234567890' }),
|
|
|
|
// }),
|
|
|
|
// ),
|
|
|
|
// repoGL,
|
|
|
|
// );
|
|
|
|
|
|
|
|
// assertRepoEntry(
|
|
|
|
// trie.get(
|
|
|
|
// repoNested.uri.with({
|
|
|
|
// scheme: 'gitlens',
|
|
|
|
// authority: 'abcd',
|
|
|
|
// query: JSON.stringify({ ref: '1234567890' }),
|
|
|
|
// }),
|
|
|
|
// ),
|
|
|
|
// repoNested,
|
|
|
|
// );
|
|
|
|
// });
|
|
|
|
|
|
|
|
it('get(file://): repo (ignore case)', () => { |
|
|
|
assertRepoEntryIgnoreCase(trie.get(repoGL.uri.with({ path: repoGL.uri.path.toUpperCase() })), repoGL); |
|
|
@ -615,34 +616,34 @@ describe('UriEntryTrie Test Suite', () => { |
|
|
|
); |
|
|
|
}); |
|
|
|
|
|
|
|
it('get(gitlens://): repo (ignore case)', () => { |
|
|
|
assertRepoEntry( |
|
|
|
trie.get( |
|
|
|
repoGL.uri.with({ |
|
|
|
scheme: 'GITLENS', |
|
|
|
authority: 'abcd', |
|
|
|
query: JSON.stringify({ ref: '1234567890' }), |
|
|
|
}), |
|
|
|
), |
|
|
|
repoGL, |
|
|
|
); |
|
|
|
|
|
|
|
assertRepoEntryIgnoreCase( |
|
|
|
trie.get( |
|
|
|
Uri.parse( |
|
|
|
repoGL.uri |
|
|
|
.with({ |
|
|
|
scheme: 'gitlens', |
|
|
|
authority: 'abcd', |
|
|
|
query: JSON.stringify({ ref: '1234567890' }), |
|
|
|
}) |
|
|
|
.toString() |
|
|
|
.toUpperCase(), |
|
|
|
), |
|
|
|
), |
|
|
|
repoGL, |
|
|
|
); |
|
|
|
}); |
|
|
|
// it('get(gitlens://): repo (ignore case)', () => {
|
|
|
|
// assertRepoEntry(
|
|
|
|
// trie.get(
|
|
|
|
// repoGL.uri.with({
|
|
|
|
// scheme: 'GITLENS',
|
|
|
|
// authority: 'abcd',
|
|
|
|
// query: JSON.stringify({ ref: '1234567890' }),
|
|
|
|
// }),
|
|
|
|
// ),
|
|
|
|
// repoGL,
|
|
|
|
// );
|
|
|
|
|
|
|
|
// assertRepoEntryIgnoreCase(
|
|
|
|
// trie.get(
|
|
|
|
// Uri.parse(
|
|
|
|
// repoGL.uri
|
|
|
|
// .with({
|
|
|
|
// scheme: 'gitlens',
|
|
|
|
// authority: 'abcd',
|
|
|
|
// query: JSON.stringify({ ref: '1234567890' }),
|
|
|
|
// })
|
|
|
|
// .toString()
|
|
|
|
// .toUpperCase(),
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// repoGL,
|
|
|
|
// );
|
|
|
|
// });
|
|
|
|
|
|
|
|
it('get(file://): file', () => { |
|
|
|
let uri = Uri.joinPath(repoGL.uri, 'src/extension.ts'); |
|
|
@ -664,19 +665,19 @@ describe('UriEntryTrie Test Suite', () => { |
|
|
|
assertFileEntry(trie.get(uri.with({ scheme: 'github' })), uri); |
|
|
|
}); |
|
|
|
|
|
|
|
it('get(gitlens://): file', () => { |
|
|
|
const uri = Uri.joinPath(repoGL.uri, 'src/extension.ts'); |
|
|
|
assertFileEntry( |
|
|
|
trie.get( |
|
|
|
uri.with({ |
|
|
|
scheme: 'gitlens', |
|
|
|
authority: 'abcd', |
|
|
|
query: JSON.stringify({ ref: '1234567890' }), |
|
|
|
}), |
|
|
|
), |
|
|
|
uri, |
|
|
|
); |
|
|
|
}); |
|
|
|
// it('get(gitlens://): file', () => {
|
|
|
|
// const uri = Uri.joinPath(repoGL.uri, 'src/extension.ts');
|
|
|
|
// assertFileEntry(
|
|
|
|
// trie.get(
|
|
|
|
// uri.with({
|
|
|
|
// scheme: 'gitlens',
|
|
|
|
// authority: 'abcd',
|
|
|
|
// query: JSON.stringify({ ref: '1234567890' }),
|
|
|
|
// }),
|
|
|
|
// ),
|
|
|
|
// uri,
|
|
|
|
// );
|
|
|
|
// });
|
|
|
|
|
|
|
|
it('get: missing file', () => { |
|
|
|
assert.strictEqual(trie.get(Uri.joinPath(repoGL.uri, 'foo/bar/baz.ts')), undefined); |
|
|
@ -707,19 +708,19 @@ describe('UriEntryTrie Test Suite', () => { |
|
|
|
); |
|
|
|
}); |
|
|
|
|
|
|
|
it('getClosest(gitlens://): file', () => { |
|
|
|
assertRepoEntry( |
|
|
|
trie.getClosest( |
|
|
|
Uri.joinPath(repoGL.uri, 'src/extension.ts').with({ |
|
|
|
scheme: 'gitlens', |
|
|
|
authority: 'abcd', |
|
|
|
query: JSON.stringify({ ref: '1234567890' }), |
|
|
|
}), |
|
|
|
true, |
|
|
|
), |
|
|
|
repoGL, |
|
|
|
); |
|
|
|
}); |
|
|
|
// it('getClosest(gitlens://): file', () => {
|
|
|
|
// assertRepoEntry(
|
|
|
|
// trie.getClosest(
|
|
|
|
// Uri.joinPath(repoGL.uri, 'src/extension.ts').with({
|
|
|
|
// scheme: 'gitlens',
|
|
|
|
// authority: 'abcd',
|
|
|
|
// query: JSON.stringify({ ref: '1234567890' }),
|
|
|
|
// }),
|
|
|
|
// true,
|
|
|
|
// ),
|
|
|
|
// repoGL,
|
|
|
|
// );
|
|
|
|
// });
|
|
|
|
|
|
|
|
it('getClosest(file://): missing repo file', () => { |
|
|
|
assertRepoEntry(trie.getClosest(Uri.joinPath(repoGL.uri, 'foo/bar/baz.ts'), true), repoGL); |
|
|
@ -736,41 +737,41 @@ describe('UriEntryTrie Test Suite', () => { |
|
|
|
); |
|
|
|
}); |
|
|
|
|
|
|
|
it('getClosest(gitlens://): missing repo file',
()
="o">=>
{ |
|
|
|
assertRepoEntry( |
|
|
|
trie.getClosest( |
|
|
|
Uri.joinPath(repoGL.uri, 'src/extension.ts').with({ |
|
|
|
scheme: 'gitlens', |
|
|
|
authority: 'abcd', |
|
|
|
query: JSON.stringify({ ref: '1234567890' }), |
|
|
|
}), |
|
|
|
true, |
|
|
|
), |
|
|
|
repoGL, |
|
|
|
); |
|
|
|
|
|
|
|
assertRepoEntry( |
|
|
|
trie.getClosest( |
|
|
|
Uri.joinPath(repoGL.uri, 'foo/bar/baz.ts').with({ |
|
|
|
scheme: 'gitlens', |
|
|
|
authority: 'abcd', |
|
|
|
query: JSON.stringify({ ref: '1234567890' }), |
|
|
|
}), |
|
|
|
), |
|
|
|
repoGL, |
|
|
|
); |
|
|
|
|
|
|
|
assertRepoEntry( |
|
|
|
trie.getClosest( |
|
|
|
Uri.joinPath(repoNested.uri, 'foo/bar/baz.ts').with({ |
|
|
|
scheme: 'gitlens', |
|
|
|
authority: 'abcd', |
|
|
|
query: JSON.stringify({ ref: '1234567890' }), |
|
|
|
}), |
|
|
|
), |
|
|
|
repoNested, |
|
|
|
); |
|
|
|
}); |
|
|
|
// it('getClosest(gitlens://): missing repo file', () => {
|
|
|
|
// assertRepoEntry(
|
|
|
|
// trie.getClosest(
|
|
|
|
// Uri.joinPath(repoGL.uri, 'src/extension.ts').with({
|
|
|
|
// scheme: 'gitlens',
|
|
|
|
// authority: 'abcd',
|
|
|
|
// query: JSON.stringify({ ref: '1234567890' }),
|
|
|
|
// }),
|
|
|
|
// true,
|
|
|
|
// ),
|
|
|
|
// repoGL,
|
|
|
|
// );
|
|
|
|
|
|
|
|
// assertRepoEntry(
|
|
|
|
// trie.getClosest(
|
|
|
|
// Uri.joinPath(repoGL.uri, 'foo/bar/baz.ts').with({
|
|
|
|
// scheme: 'gitlens',
|
|
|
|
// authority: 'abcd',
|
|
|
|
// query: JSON.stringify({ ref: '1234567890' }),
|
|
|
|
// }),
|
|
|
|
// ),
|
|
|
|
// repoGL,
|
|
|
|
// );
|
|
|
|
|
|
|
|
// assertRepoEntry(
|
|
|
|
// trie.getClosest(
|
|
|
|
// Uri.joinPath(repoNested.uri, 'foo/bar/baz.ts').with({
|
|
|
|
// scheme: 'gitlens',
|
|
|
|
// authority: 'abcd',
|
|
|
|
// query: JSON.stringify({ ref: '1234567890' }),
|
|
|
|
// }),
|
|
|
|
// ),
|
|
|
|
// repoNested,
|
|
|
|
// );
|
|
|
|
// });
|
|
|
|
|
|
|
|
it("getClosest: path doesn't exists anywhere", () => { |
|
|
|
assert.strictEqual( |
|
|
@ -780,7 +781,7 @@ describe('UriEntryTrie Test Suite', () => { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
describe('Repositories Test Suite', () => { |
|
|
|
describe('UriTrie(Repositories) Test Suite', () => { |
|
|
|
type Repo = { type: 'repo'; name: string; uri: Uri; fsPath: string }; |
|
|
|
|
|
|
|
const repoGL: Repo = { |
|
|
@ -808,7 +809,7 @@ describe('Repositories Test Suite', () => { |
|
|
|
fsPath: 'github/microsoft/vscode', |
|
|
|
}; |
|
|
|
|
|
|
|
const trie = new UriTrie<Repo>(); |
|
|
|
const trie = new UriTrie<Repo>(normalizeRepoUri); |
|
|
|
|
|
|
|
function assertRepoEntry(actual: Repo | undefined, expected: Repo): void { |
|
|
|
// assert.strictEqual(actual?.path, expected.name);
|
|
|
|