New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refs/stash@0 is not a valid reference #1121
Comments
What's your shell, MSYS2? I haven't heard about that. I assume it parses something differently, because from your logs we can see this:
|
I wonder if the curly braces are being interpreted by some layer. @ext if you open ./node_modules/lint-staged and search for this refs/stash@{0} bit Escaping the curly braces may fix the issue |
Running
That actually does the trick, I've modified - return `refs/stash@{${index}}`
+ return `refs/stash@\\{${index}\\}` With that modification everything now works as expected:
I dont know if that is a reasonable change or the proper location for it. I could try running the test-cases in this repo and create a PR if you want.
|
@ext if you open a PR, we can run the integration tests on all platform and see if they pass. |
The change causes the integration tests to fail on other platforms, I'm going to look a bit deeper at the call to https://github.com/ext/lint-staged/runs/5838527402?check_suite_focus=true |
You could simply check for your specific terminal and escape things appropriately. I think we chalk it up to git stash using a syntax that happens to be identical to bash. There's probably a different syntax, instead of stash@{0} maybe something like refs/stashes/0 works idk |
@wangrongding use |
Ha ha~ I didn't read the doc. |
Took me a while to get some time to investigate further, still not sure what the issue is but it seems like const execa = require("execa");
async function run(cmd, args) {
const { stdout } = await execa(cmd, args);
console.log(stdout);
}
async function test1() {
console.log('test 1 - node');
await run("node", ["-p", "process.argv.slice(1)", "refs/stash@{0}"]);
}
async function test2() {
console.log('test 2 - git');
await run("git", ["show", "refs/stash@{0}"]);
}
(async () =>{
await test1();
await test2();
})(); I use code similar to
Running - await run("git", ["show", "refs/stash@{0}"]);
+ await run("bash", ["-c", "git show refs/stash@{0}"]); Similarly using The issue doesn't appear to be within |
By looking at your output it seems that the first commands argument get evaluated somehow. Can this be the case? |
Probable, any suggestion to how to confirm that? As with earlier comments, escaping - await run("git", ["show", "refs/stash@{0}"]);
+ await run("git", ["show", "refs/stash@\\{0\\}"]); I tried switching out
I appreciate you all taking time to assist with this even if it isn't bug in this software ❤️ |
Can it be bash-related? |
If we can detect |
I fished around for a I think learning what execa is doing, reading execa docs, etc, is the way to go. It's a decent package, but it's very full featured and I've found reading the docs to be quite important. |
In theory git commits can function as "stashes", but that would probably require a bit of re-work |
It might be possible to use |
which git version would that require? |
Also check this out: https://stackoverflow.com/a/41008657/565877 We can manually create refs May be nicer than stashes |
I have a similar issue, tried doing development on a windows machine today and got this error, fixed it by adding:
Below the fix in #1178 |
Description
Running
lint-staged@123.7
under MSYS2 in Windows 10 but otherwise nothing fancy.Debug Logs
expand to view
Environment
lint-staged
: 12.3.7The text was updated successfully, but these errors were encountered: