diff --git a/.circleci/config.yml b/.circleci/config.yml index 9b5c16f7..9675b616 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -7,6 +7,10 @@ jobs: description: Runs NUTs from other (external) repos by cloning them. Substitutes a dependency for the current pull request. For example, you're testing a PR to a library and want to test a plugin in another repo that uses the library. parameters: + test_command: + type: string + description: 'command to execute (ex: yarn test:nuts)' + default: 'yarn test:nuts' node_version: description: version of node to run tests against type: string @@ -106,7 +110,7 @@ jobs: - run: name: Nuts command: | - yarn test:nuts:tracking + <> workflows: version: 2 @@ -155,12 +159,22 @@ workflows: - release-management/test-package - release-management/test-nut sfdx_version: latest - size: large + size: medium matrix: parameters: os: [linux, windows] node_version: [lts] external_project_git_url: ['https://github.com/salesforcecli/plugin-source'] + test_command: + [ + 'yarn test:nuts:tracking:basics', + 'yarn test:nuts:tracking:conflicts', + 'yarn test:nuts:tracking:forceignore', + 'yarn test:nuts:tracking:remote', + 'yarn test:nuts:tracking:resetClear', + 'yarn test:nuts:tracking:lwc', + 'yarn mocha "test/nuts/trackingCommands/mpd-*.nut.ts" --slow 3000 --timeout 600000 --parallel', + ] - release-management/release-package: github-release: true requires: diff --git a/src/shared/localShadowRepo.ts b/src/shared/localShadowRepo.ts index 65f2a06d..deeebf1b 100644 --- a/src/shared/localShadowRepo.ts +++ b/src/shared/localShadowRepo.ts @@ -79,6 +79,7 @@ export class ShadowRepo { this.logger.debug('initializing git repo'); await this.gitInit(); } + await this.locateIgnoreFiles(); } /** @@ -88,7 +89,6 @@ export class ShadowRepo { public async gitInit(): Promise { await fs.promises.mkdir(this.gitDir, { recursive: true }); await git.init({ fs, dir: this.projectPath, gitdir: this.gitDir, defaultBranch: 'main' }); - await this.locateIgnoreFiles(); } /** @@ -265,17 +265,11 @@ export class ShadowRepo { dir: this.projectPath, gitdir: this.gitDir, trees: [git.WORKDIR()], - // TODO: this can be marginally faster if we limit it to pkgDirs and toplevel project files // eslint-disable-next-line @typescript-eslint/require-await map: async (filepath: string) => filepath, })) as string[] ) - .filter( - (filepath) => - filepath.includes(gitIgnoreFileName) && - // can be top-level like '.' (no sep) OR must be in one of the package dirs - (!filepath.includes(path.sep) || this.packageDirs.some((dir) => pathIsInFolder(filepath, dir.name))) - ) + .filter((filepath) => filepath.includes(gitIgnoreFileName)) .map((ignoreFile) => path.join(this.projectPath, ignoreFile)); } diff --git a/test/nuts/local/nonTopLevelIgnore.nut.ts b/test/nuts/local/nonTopLevelIgnore.nut.ts index a40cf36e..36c06502 100644 --- a/test/nuts/local/nonTopLevelIgnore.nut.ts +++ b/test/nuts/local/nonTopLevelIgnore.nut.ts @@ -10,7 +10,7 @@ import { fs } from '@salesforce/core'; import { expect } from 'chai'; import { ShadowRepo } from '../../../src/shared/localShadowRepo'; -describe('handles non-top-level ignore', () => { +describe('handles non-top-level ignore inside project dir', () => { let session: TestSession; let repo: ShadowRepo; @@ -43,3 +43,37 @@ describe('handles non-top-level ignore', () => { await session?.clean(); }); }); + +describe('handles non-top-level ignore outside project dir', () => { + let session: TestSession; + let repo: ShadowRepo; + + before(async () => { + session = await TestSession.create({ + project: { + sourceDir: path.join('test', 'nuts', 'repros', 'nested-classes2'), + }, + 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(); + }); +});