-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: distributed .gitignore and loose pkgDir matching
- Loading branch information
Showing
9 changed files
with
200 additions
and
18 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
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
Submodule ignoreInSubfolder
added at
3dd459
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright (c) 2020, salesforce.com, inc. | ||
* All rights reserved. | ||
* Licensed under the BSD 3-Clause license. | ||
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
import * as path from 'path'; | ||
import { TestSession } from '@salesforce/cli-plugins-testkit'; | ||
import { fs } from '@salesforce/core'; | ||
import { expect } from 'chai'; | ||
import { ShadowRepo } from '../../src/shared/localShadowRepo'; | ||
|
||
describe('handles non-top-level ignore', () => { | ||
let session: TestSession; | ||
let repo: ShadowRepo; | ||
|
||
before(async () => { | ||
session = await TestSession.create({ | ||
project: { | ||
sourceDir: path.join('test', 'nuts', 'ignoreInSubfolder', 'nested-classes'), | ||
}, | ||
authStrategy: 'NONE', | ||
}); | ||
}); | ||
|
||
it('initialize the local tracking', async () => { | ||
repo = await ShadowRepo.getInstance({ | ||
orgId: 'fakeOrgId2', | ||
projectPath: session.project.dir, | ||
packageDirs: [{ path: 'classes', name: 'classes', fullPath: path.join(session.project.dir, 'classes') }], | ||
}); | ||
// verify the local tracking files/directories | ||
expect(fs.existsSync(repo.gitDir)); | ||
}); | ||
|
||
it('should not be influenced by gitignore', async () => { | ||
expect(await repo.getChangedFilenames()) | ||
.to.be.an('array') | ||
.with.length(2); | ||
}); | ||
|
||
after(async () => { | ||
await session?.clean(); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright (c) 2020, salesforce.com, inc. | ||
* All rights reserved. | ||
* Licensed under the BSD 3-Clause license. | ||
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
import * as path from 'path'; | ||
import { TestSession } from '@salesforce/cli-plugins-testkit'; | ||
import { fs } from '@salesforce/core'; | ||
import { expect } from 'chai'; | ||
import { ShadowRepo } from '../../src/shared/localShadowRepo'; | ||
|
||
describe('verifies exact match of pkgDirs', () => { | ||
let session: TestSession; | ||
let repo: ShadowRepo; | ||
|
||
before(async () => { | ||
session = await TestSession.create({ | ||
project: { | ||
sourceDir: path.join('test', 'nuts', 'ignoreInSubfolder', 'extra-classes'), | ||
}, | ||
authStrategy: 'NONE', | ||
}); | ||
}); | ||
|
||
it('initialize the local tracking', async () => { | ||
repo = await ShadowRepo.getInstance({ | ||
orgId: 'fakeOrgId3', | ||
projectPath: session.project.dir, | ||
packageDirs: [{ path: 'force-app', name: 'force-app', fullPath: path.join(session.project.dir, 'force-app') }], | ||
}); | ||
// verify the local tracking files/directories | ||
expect(fs.existsSync(repo.gitDir)); | ||
}); | ||
|
||
it('should not include files from force-app-extra', async () => { | ||
const changedFilenames = await repo.getChangedFilenames(); | ||
|
||
// expect(changedFilenames).to.be.an('array').with.length(2); | ||
changedFilenames.map((f) => { | ||
expect(f).to.not.contain('force-app-extra'); | ||
}); | ||
}); | ||
|
||
after(async () => { | ||
await session?.clean(); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright (c) 2020, salesforce.com, inc. | ||
* All rights reserved. | ||
* Licensed under the BSD 3-Clause license. | ||
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
import { normalize } from 'path'; | ||
import { expect } from 'chai'; | ||
import { pathIsInFolder } from '../../src/shared/functions'; | ||
|
||
describe('stringStartsWithString', () => { | ||
it('does not misidentify partial strings', () => { | ||
expect(pathIsInFolder(normalize('/foo/bar-extra/baz'), normalize('/foo/bar'))).to.equal(false); | ||
}); | ||
|
||
it('does not misidentify partial strings (inverse)', () => { | ||
expect(pathIsInFolder(normalize('/foo/bar-extra/baz'), normalize('/foo/bar-extra'))).to.equal(true); | ||
}); | ||
|
||
it('single top-level dir is ok', () => { | ||
expect(pathIsInFolder(normalize('/foo/bar-extra/baz'), normalize('/foo'))).to.equal(true); | ||
}); | ||
|
||
it('no initial separator on 1st arg is ok', () => { | ||
expect(pathIsInFolder(normalize('/foo/bar-extra/baz'), 'foo')).to.equal(true); | ||
}); | ||
|
||
it('no initial separator on 2nd arg is ok', () => { | ||
expect(pathIsInFolder(normalize('foo/bar-extra/baz'), '/foo')).to.equal(true); | ||
}); | ||
|
||
it('works for deep children', () => { | ||
expect(pathIsInFolder(normalize('/foo/bar-extra/baz/some/deep/path'), normalize('/foo/bar-extra/baz'))).to.equal( | ||
true | ||
); | ||
}); | ||
}); |