Skip to content

Commit

Permalink
fix(filter-workspace-packages): filter not working if the path contai…
Browse files Browse the repository at this point in the history
…ns Korean characters (#4595)
  • Loading branch information
WhiteKiwi committed Apr 20, 2022
1 parent 4170ead commit 9f06162
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/funny-mirrors-act.md
@@ -0,0 +1,5 @@
---
"@pnpm/filter-workspace-packages": patch
---

'filter-workspace-packages' will filter the package well even if Korean is included in the path. fix #4594
2 changes: 2 additions & 0 deletions packages/filter-workspace-packages/src/getChangedPackages.ts
Expand Up @@ -64,6 +64,8 @@ async function getChangedDirsSinceCommit (commit: string, workingDir: string, te
}

const allChangedFiles = diff.split('\n')
// The prefix and suffix '"' are appended to the Korean path
.map(line => line.replace(/^"/, '').replace(/"$/, ''))
const patterns = changedFilesIgnorePattern.filter(
(pattern) => pattern.length
)
Expand Down
19 changes: 17 additions & 2 deletions packages/filter-workspace-packages/test/index.ts
Expand Up @@ -366,6 +366,11 @@ test('select changed packages', async () => {

await mkdir(pkg3Dir)

const pkgKorDir = path.join(workspaceDir, 'package-kor')

await mkdir(pkgKorDir)
await touch(path.join(pkgKorDir, 'fileKor한글.js'))

await execa('git', ['add', '.'], { cwd: workspaceDir })
await execa('git', ['commit', '--allow-empty-message', '-m', '', '--no-gpg-sign'], { cwd: workspaceDir })

Expand Down Expand Up @@ -412,6 +417,16 @@ test('select changed packages', async () => {
},
},
},
[pkgKorDir]: {
dependencies: [],
package: {
dir: pkgKorDir,
manifest: {
name: 'package-kor',
version: '0.0.0',
},
},
},
[pkg20Dir]: {
dependencies: [],
package: {
Expand All @@ -429,7 +444,7 @@ test('select changed packages', async () => {
diff: 'HEAD~1',
}], { workspaceDir })

expect(Object.keys(selectedProjectsGraph)).toStrictEqual([pkg1Dir, pkg2Dir])
expect(Object.keys(selectedProjectsGraph)).toStrictEqual([pkg1Dir, pkg2Dir, pkgKorDir])
}
{
const { selectedProjectsGraph } = await filterWorkspacePackages(pkgsGraph, [{
Expand All @@ -453,7 +468,7 @@ test('select changed packages', async () => {
includeDependents: true,
}], { workspaceDir, testPattern: ['*/file2.js'] })

expect(Object.keys(selectedProjectsGraph)).toStrictEqual([pkg1Dir, pkg2Dir])
expect(Object.keys(selectedProjectsGraph)).toStrictEqual([pkg1Dir, pkgKorDir, pkg2Dir])
}
})

Expand Down

2 comments on commit 9f06162

@WhiteKiwi
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zkochan Hi!
There seems to be a problem with the pipeline.
I'm leaving a comment because it looks like a re-run is needed. 🙇
https://github.com/pnpm/pnpm/runs/6095436519?check_suite_focus=true

@zkochan
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know, it sometimes hangs

Please sign in to comment.