-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Self-service
- I'd be willing to implement a fix
Describe the bug
In CI/CD pipelines for big Git repositories it's very common to use a very limited Git refspec and shallow clone depth to reduce Git clone data transfer etc.
But the simple operation of yarn version 1.2.3 -i will fail with:
Usage Error: No ancestor could be found between any of HEAD and master, origin/master, upstream/master, main, origin/main, upstream/main
As far as I can tell this is because of https://github.com/yarnpkg/berry/blob/%40yarnpkg/cli/4.10.3/packages/plugin-version/sources/versionUtils.ts#L177-L185
But why would this be necessary? When providing an explicit valid SemVer version to yarn version and using the --immediate flag, I don't see why any Git operations would be necessary.
Right now I'm having to resort to stupid workarounds like:
mv .git ..git
yarn version 1.2.3 -i
mv ..git .git
To reproduce
Git clone without any refs to master, origin/master, upstream/master, main, origin/main, upstream/main.
yarn version 1.2.3 -i
Environment
System:
OS: Linux 5.14 Fedora Linux 42 (Container Image)
CPU: (16) x64 INTEL(R) XEON(R) GOLD 6548N
Binaries:
Node: 20.19.5 - /tmp/xfs-2c53a947/node
Yarn: 4.10.3 - /tmp/xfs-2c53a947/yarn
npm: 10.8.2 - /opt/tools/node/bin/npmAdditional context
No response