ds300 / patch-package

Fix broken node modules instantly 🏃🏽‍♀️💨
MIT License
10.31k stars 288 forks source link

Patch parse error: Explicitly state src-prefix & dest-prefix for git diff command #394

Closed tye-singwa closed 1 year ago

tye-singwa commented 2 years ago

Hi! i've encounter an issue when using this tool. It failed with patch parsing error. From logs i could see that somehow my system setup uses different prefixes while producing patch file.

Here is first line of produced patch:

diff --git i/node_modules/@storybook/ui/paths.js c/node_modules/@storybook/ui/paths.js

I suggest adding options (https://git-scm.com/docs/git-diff#Documentation/git-diff.txt---src-prefixltprefixgt & https://git-scm.com/docs/git-diff#Documentation/git-diff.txt---dst-prefixltprefixgt) explicitly here
https://github.com/ds300/patch-package/blob/5c2c92bf504885fba4840870a23fc8999c00e572/src/makePatch.ts#L211-L217 like this

 const diffResult = git( 
   "diff", 
   "--cached", 
   "--no-color", 
   "--ignore-space-at-eol", 
   "--no-ext-diff", 
   "--src-prefix=a/",
   "--dst-prefix=b/"
 );

Thanks