Skip to content

Commit

Permalink
GH-165: Initial attempt to fix broken tests on Windows.
Browse files Browse the repository at this point in the history
Signed-off-by: Akos Kitta <kittaakos@gmail.com>
  • Loading branch information
kittaakos committed Sep 29, 2017
1 parent 2dd58c9 commit 5298d0f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
24 changes: 21 additions & 3 deletions packages/git/src/node/dugite-git.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('git', async () => {

it('should discover all nested repositories', async () => {

const root = track.mkdirSync('discovery-test');
const root = track.mkdirSync('discovery-test-1');
fs.mkdirSync(path.join(root, 'A'));
fs.mkdirSync(path.join(root, 'B'));
fs.mkdirSync(path.join(root, 'C'));
Expand All @@ -33,9 +33,9 @@ describe('git', async () => {

});

it('should discover all nested repositories and the root repository', async () => {
it('should discover all nested repositories and the root repository which is at the workspace root', async () => {

const root = track.mkdirSync('discovery-test');
const root = track.mkdirSync('discovery-test-2');
fs.mkdirSync(path.join(root, 'BASE'));
fs.mkdirSync(path.join(root, 'BASE', 'A'));
fs.mkdirSync(path.join(root, 'BASE', 'B'));
Expand All @@ -46,6 +46,24 @@ describe('git', async () => {
await initRepository(path.join(root, 'BASE', 'C'));
const git = await createGit(path.join(root, 'BASE'));
const repositories = await git.repositories();
expect(repositories.map(r => path.basename(FileUri.fsPath(r.localUri))).sort()).to.deep.equal(['A', 'B', 'BASE', 'C']);

});

it('should discover all nested repositories and the container repository', async () => {

const root = track.mkdirSync('discovery-test-3');
fs.mkdirSync(path.join(root, 'BASE'));
fs.mkdirSync(path.join(root, 'BASE', 'WS_ROOT'));
fs.mkdirSync(path.join(root, 'BASE', 'WS_ROOT', 'A'));
fs.mkdirSync(path.join(root, 'BASE', 'WS_ROOT', 'B'));
fs.mkdirSync(path.join(root, 'BASE', 'WS_ROOT', 'C'));
await initRepository(path.join(root, 'BASE'));
await initRepository(path.join(root, 'BASE', 'WS_ROOT', 'A'));
await initRepository(path.join(root, 'BASE', 'WS_ROOT', 'B'));
await initRepository(path.join(root, 'BASE', 'WS_ROOT', 'C'));
const git = await createGit(path.join(root, 'BASE', 'WS_ROOT'));
const repositories = await git.repositories();
const repositoryNames = repositories.map(r => path.basename(FileUri.fsPath(r.localUri)));
expect(repositoryNames.shift()).to.equal('BASE'); // The first must be the container repository.
expect(repositoryNames.sort()).to.deep.equal(['A', 'B', 'C']);
Expand Down
3 changes: 2 additions & 1 deletion packages/git/src/node/dugite-git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ export class DugiteGit implements Git {
const containerRepositoryPromise = this.getContainerRepository(workspaceRootPath);
const repositories = await repositoriesPromise;
const containerRepository = await containerRepositoryPromise;
if (containerRepository) {
// Make sure not to add the container to the repositories twice. Can happen when WS root is a git repository.
if (containerRepository && repositories.map(r => r.localUri).indexOf(containerRepository.localUri) === -1) {
repositories.unshift(containerRepository);
}
return repositories;
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1926,9 +1926,9 @@ dtrace-provider@~0.8:
dependencies:
nan "^2.3.3"

dugite-extra@0.0.1-alpha.9:
version "0.0.1-alpha.9"
resolved "https://registry.yarnpkg.com/dugite-extra/-/dugite-extra-0.0.1-alpha.9.tgz#1febe6f0c841cba3e6ecd13b4145804e528cd8fb"
dugite-extra@0.0.1-alpha.10:
version "0.0.1-alpha.10"
resolved "https://registry.yarnpkg.com/dugite-extra/-/dugite-extra-0.0.1-alpha.10.tgz#5ce83da4ddd3894ad5a8813d041f42841b10ea36"
dependencies:
byline "^5.0.0"
dugite "1.42.0"
Expand Down

0 comments on commit 5298d0f

Please sign in to comment.