auto-commit-msg
auto-commit-msg copied to clipboard
Special characters in filenames are not properly encoded
If filenames contain non-ASCII characters this can lead to unexpected commit message suggestions. See for example this screenshot:
hmm thanks. I was able to reproduce
but when I added unit tests, they pass.
e.g.
describe("handle special characters in filenames", function () {
it("should correctly parse a filename with special characters", function () {
const expected: FileChange = {
x: "A",
y: " ",
from: "abcëxyz.md",
to: "",
};
assert.deepStrictEqual(parseDiffIndex("A\tabcëxyz.md"), expected);
});
});
The problem is the git commands. I'll keep looking at this
$ npm run sb
$ cd sandbox
$ git add sp*
$ git ls
README.md
bazz.js
buzz.js
fizz.js
foo.js
"sp\303\253cial ch\303\242racters.md"
Can you do this in your repo or globally across repos with --global?
git config core.quotePath false
Then try again and let me know if that works?
I started implementing a fix in the code but it touched a couple of files and then at some point the sandbox won't start beacuse of some error in vs code so I am stuck for now
@MichaelCurrin With core.quotePath false it behaves as expected.
If you call git within your code, you might simply want to add the matching config parameter using -c like in the following example:
git -c 'core.quotePath=false' ls-files
from my quick testing it looks like that works.
I've pushed the change on master if you want to build and install locally
git clone ... make all make e
I am not going to publish the change yet as a new version of the extension
Hi, I've published a new version
Nice, but for me the new version throws this error (on Windows)
2024-11-03 19:51:18.261 [error] Error: Command failed: git -c 'core.quotePath=false' diff-index --name-status --find-renames --find-copies --no-color --cached HEAD
error: invalid key: 'core.quotePath
fatal: unable to parse command-line config
at genericNodeError (node:internal/errors:984:15)
at wrappedFn (node:internal/errors:538:14)
at ChildProcess.exithandler (node:child_process:423:12)
at ChildProcess.emit (node:events:519:28)
at maybeClose (node:internal/child_process:1105:16)
at ChildProcess._handle.onexit (node:internal/child_process:305:5) commitMsg.autofill {"value":"MichaelCurrin.auto-commit-msg","_lower":"michaelcurrin.auto-commit-msg"}
Running the command from the error message works as expected in Powershell…
In CMD I can recreate the error:
C:\Users\phili\dev\philips-wiki>git -c 'core.quotePath=false' diff-index --name-status --find-renames --find-copies --no-color --cached HEAD
error: invalid key: 'core.quotePath
fatal: unable to parse command-line config
Using double quotes or no quotes at all works though
EDIT: Single Quotes in CMD are just regular characters, so it is expected to not work in cmd
@MichaelCurrin I prepared #114 with a fix
And by now I am sorry that I did not build the earlier version myself and test it. Then the (on Windows) broken release could have been prevented :/