Skip to content

Commit

Permalink
fix: sub directory detection when walking vcs content (#880)
Browse files Browse the repository at this point in the history
* fix: subDir detection when walking the repo content

* build: upgrade dependencies
  • Loading branch information
scolladon authored Jun 8, 2024
1 parent eb5a47b commit 788478d
Show file tree
Hide file tree
Showing 4 changed files with 585 additions and 502 deletions.
23 changes: 23 additions & 0 deletions __tests__/unit/lib/adapter/GitAdapter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,29 @@ describe('GitAdapter', () => {
})

describe('when filepath should be treated', () => {
describe(`when "config.source" is '.'`, () => {
it('returns the normalized path', async () => {
// Arrange
const firstEntry = {
type: jest.fn(() => Promise.resolve('blob')),
oid: jest.fn(() => undefined),
} as unknown as WalkerEntry
const secondEntry = {
type: jest.fn(() => Promise.resolve('blob')),
oid: jest.fn(() => 10),
} as unknown as WalkerEntry

// Act
const result = await diffLineWalker({
...config,
source: '.',
})('force-app/test.file', [firstEntry, secondEntry])

// Assert
expect(result).toBe('A\tforce-app/test.file')
})
})

describe(`when filepath starts with "config.source"`, () => {
it('returns the normalized path', async () => {
// Arrange
Expand Down
24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
"author": "Sebastien Colladon <[email protected]>",
"dependencies": {
"@salesforce/command": "^5.3.9",
"@salesforce/core": "^7.3.6",
"@salesforce/core": "^7.3.10",
"async": "^3.2.5",
"fast-xml-parser": "^4.3.6",
"fast-xml-parser": "^4.4.0",
"fs-extra": "^11.2.0",
"ignore": "^5.3.1",
"isomorphic-git": "^1.25.10",
Expand Down Expand Up @@ -194,18 +194,18 @@
"@commitlint/config-conventional": "^19.2.2",
"@jest/globals": "^29.7.0",
"@oclif/dev-cli": "^1.26.10",
"@salesforce/cli-plugins-testkit": "^5.3.4",
"@salesforce/cli-plugins-testkit": "^5.3.9",
"@salesforce/dev-config": "^4.1.0",
"@salesforce/ts-sinon": "^1.4.19",
"@stryker-mutator/core": "^8.2.6",
"@stryker-mutator/jest-runner": "^8.2.6",
"@swc/core": "^1.5.7",
"@swc/core": "^1.5.25",
"@types/async": "^3.2.24",
"@types/jest": "^29.5.12",
"@types/mocha": "^10.0.6",
"@types/node": "^20.12.12",
"@typescript-eslint/eslint-plugin": "^7.9.0",
"@typescript-eslint/parser": "^7.9.0",
"@types/node": "^20.14.2",
"@typescript-eslint/eslint-plugin": "^7.12.0",
"@typescript-eslint/parser": "^7.12.0",
"benchmark": "^2.1.4",
"chai": "^4.3.10",
"eslint": "^8.57.0",
Expand All @@ -214,16 +214,16 @@
"eslint-plugin-prettier": "^5.1.3",
"husky": "^9.0.11",
"jest": "^29.7.0",
"knip": "^5.16.0",
"lint-staged": "^15.2.2",
"knip": "^5.17.4",
"lint-staged": "^15.2.5",
"mocha": "^10.4.0",
"nyc": "^15.1.0",
"prettier": "^3.2.5",
"prettier": "^3.3.1",
"shx": "^0.3.4",
"sinon": "^18.0.0",
"ts-jest": "^29.1.2",
"ts-jest": "^29.1.4",
"ts-node": "^10.9.2",
"tslib": "^2.6.2",
"tslib": "^2.6.3",
"typescript": "^5.4.5",
"wireit": "^0.14.4",
"yarn-audit-fix": "^10.0.7",
Expand Down
4 changes: 2 additions & 2 deletions src/adapter/GitAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
import type { Config } from '../types/config'
import type { FileGitRef } from '../types/git'
import { SOURCE_DEFAULT_VALUE } from '../utils/cliConstants'
import { dirExists, fileExists, treatPathSep } from '../utils/fsUtils'
import { dirExists, fileExists, isSubDir, treatPathSep } from '../utils/fsUtils'
import { getLFSObjectContentPath, isLFS } from '../utils/gitLfsHelper'

const firstCommitParams = ['rev-list', '--max-parents=0', 'HEAD']
Expand Down Expand Up @@ -293,7 +293,7 @@ const pathDoesNotStartsWith = (root: string) => {

return (path: string) =>
gitFormattedRoot !== SOURCE_DEFAULT_VALUE &&
!path.startsWith(gitFormattedRoot)
!isSubDir(gitFormattedRoot, path)
}

const evaluateShouldSkip = (base: string) => {
Expand Down
Loading

0 comments on commit 788478d

Please sign in to comment.