From dab5df115921f6c1a4038c53c1714d672b2ad5c9 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sat, 20 Aug 2022 16:11:58 -0400 Subject: [PATCH 1/4] use single-quote to avoid $ characters wreaking havoc - fixes #6113 --- packages/migrate/migrations/routes/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/migrate/migrations/routes/utils.js b/packages/migrate/migrations/routes/utils.js index 0b2bb99c9a50..cbac52d4918e 100644 --- a/packages/migrate/migrations/routes/utils.js +++ b/packages/migrate/migrations/routes/utils.js @@ -46,7 +46,7 @@ export function error(description, comment_id) { */ export function move_file(file, renamed, content, use_git) { if (use_git) { - execSync(`git mv ${JSON.stringify(file)} ${JSON.stringify(renamed)}`); + execSync(`git mv '${file.replace(/'/g, "\\'")}' '${renamed.replace(/'/g, "\\'")}'`); } else { fs.unlinkSync(file); } From d8e951a17cd730bc6a5f6d2e279376d673bb1fe0 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sat, 20 Aug 2022 16:12:43 -0400 Subject: [PATCH 2/4] changeset --- .changeset/unlucky-cameras-appear.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/unlucky-cameras-appear.md diff --git a/.changeset/unlucky-cameras-appear.md b/.changeset/unlucky-cameras-appear.md new file mode 100644 index 000000000000..5b539b3d3622 --- /dev/null +++ b/.changeset/unlucky-cameras-appear.md @@ -0,0 +1,5 @@ +--- +'svelte-migrate': patch +--- + +[fix] git mv files correctly when they contain \$ characters From e40d0949f0d50f10d924aeae337e9e892f7ecb16 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sat, 20 Aug 2022 16:48:59 -0400 Subject: [PATCH 3/4] use shell-quote package --- packages/migrate/migrations/routes/utils.js | 3 ++- packages/migrate/package.json | 1 + pnpm-lock.yaml | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/migrate/migrations/routes/utils.js b/packages/migrate/migrations/routes/utils.js index cbac52d4918e..2eca6800e967 100644 --- a/packages/migrate/migrations/routes/utils.js +++ b/packages/migrate/migrations/routes/utils.js @@ -3,6 +3,7 @@ import path from 'path'; import colors from 'kleur'; import ts from 'typescript'; import MagicString from 'magic-string'; +import sq from 'shell-quote'; import { execSync } from 'child_process'; /** @param {string} message */ @@ -46,7 +47,7 @@ export function error(description, comment_id) { */ export function move_file(file, renamed, content, use_git) { if (use_git) { - execSync(`git mv '${file.replace(/'/g, "\\'")}' '${renamed.replace(/'/g, "\\'")}'`); + execSync(`git mv ${sq.quote([file, renamed])}`); } else { fs.unlinkSync(file); } diff --git a/packages/migrate/package.json b/packages/migrate/package.json index c5ac8be47337..3993d22cc0d2 100644 --- a/packages/migrate/package.json +++ b/packages/migrate/package.json @@ -23,6 +23,7 @@ "kleur": "^4.1.4", "magic-string": "^0.26.2", "prompts": "^2.4.2", + "shell-quote": "^1.7.3", "tiny-glob": "^0.2.9", "typescript": "^4.7.4" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0670c9c9269e..761479279250 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -502,6 +502,7 @@ importers: magic-string: ^0.26.2 prettier: ^2.6.2 prompts: ^2.4.2 + shell-quote: ^1.7.3 tiny-glob: ^0.2.9 typescript: ^4.7.4 uvu: ^0.5.6 @@ -509,6 +510,7 @@ importers: kleur: 4.1.5 magic-string: 0.26.2 prompts: 2.4.2 + shell-quote: 1.7.3 tiny-glob: 0.2.9 typescript: 4.7.4 devDependencies: @@ -3671,6 +3673,10 @@ packages: engines: {node: '>=8'} dev: true + /shell-quote/1.7.3: + resolution: {integrity: sha512-Vpfqwm4EnqGdlsBFNmHhxhElJYrdfcxPThu+ryKS5J8L/fhAwLazFZtq+S+TWZ9ANj2piSQLGj6NQg+lKPmxrw==} + dev: false + /shiki-twoslash/3.1.0: resolution: {integrity: sha512-uDqrTutOIZzyHbo103GsK7Vvc10saK1XCCivnOQ1NHJzgp3FBilEpftGeVzVSMOJs+JyhI7whkvhXV7kXQ5zCg==} dependencies: From 4fe6202fb587a09bfbd2b07be38c381b067a407a Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sat, 20 Aug 2022 18:33:44 -0400 Subject: [PATCH 4/4] do this instead --- packages/migrate/migrations/routes/utils.js | 5 ++--- packages/migrate/package.json | 1 - pnpm-lock.yaml | 6 ------ 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/packages/migrate/migrations/routes/utils.js b/packages/migrate/migrations/routes/utils.js index 2eca6800e967..23d850e031c9 100644 --- a/packages/migrate/migrations/routes/utils.js +++ b/packages/migrate/migrations/routes/utils.js @@ -3,8 +3,7 @@ import path from 'path'; import colors from 'kleur'; import ts from 'typescript'; import MagicString from 'magic-string'; -import sq from 'shell-quote'; -import { execSync } from 'child_process'; +import { execFileSync } from 'child_process'; /** @param {string} message */ export function bail(message) { @@ -47,7 +46,7 @@ export function error(description, comment_id) { */ export function move_file(file, renamed, content, use_git) { if (use_git) { - execSync(`git mv ${sq.quote([file, renamed])}`); + execFileSync('git', ['mv', file, renamed]); } else { fs.unlinkSync(file); } diff --git a/packages/migrate/package.json b/packages/migrate/package.json index 3993d22cc0d2..c5ac8be47337 100644 --- a/packages/migrate/package.json +++ b/packages/migrate/package.json @@ -23,7 +23,6 @@ "kleur": "^4.1.4", "magic-string": "^0.26.2", "prompts": "^2.4.2", - "shell-quote": "^1.7.3", "tiny-glob": "^0.2.9", "typescript": "^4.7.4" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 761479279250..0670c9c9269e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -502,7 +502,6 @@ importers: magic-string: ^0.26.2 prettier: ^2.6.2 prompts: ^2.4.2 - shell-quote: ^1.7.3 tiny-glob: ^0.2.9 typescript: ^4.7.4 uvu: ^0.5.6 @@ -510,7 +509,6 @@ importers: kleur: 4.1.5 magic-string: 0.26.2 prompts: 2.4.2 - shell-quote: 1.7.3 tiny-glob: 0.2.9 typescript: 4.7.4 devDependencies: @@ -3673,10 +3671,6 @@ packages: engines: {node: '>=8'} dev: true - /shell-quote/1.7.3: - resolution: {integrity: sha512-Vpfqwm4EnqGdlsBFNmHhxhElJYrdfcxPThu+ryKS5J8L/fhAwLazFZtq+S+TWZ9ANj2piSQLGj6NQg+lKPmxrw==} - dev: false - /shiki-twoslash/3.1.0: resolution: {integrity: sha512-uDqrTutOIZzyHbo103GsK7Vvc10saK1XCCivnOQ1NHJzgp3FBilEpftGeVzVSMOJs+JyhI7whkvhXV7kXQ5zCg==} dependencies: