-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Branch/tag resolution for git dependencies #3720
Comments
@sheerun wanted to address a similar issue #3624 (comment) |
The feature of yarn.lock is that it guarantees repeatable builds. |
Thanks @bestander. In this case, we'd still freeze the branch to its current commit. |
I see, there is still confusion, I think we need to have more fields tracking git dependencies: branch, tag, commit hash, tarball hash (if using offline mirror). Regarding this bug, help from community members is welcome |
Is there any documentation or specification about the algorithms in If I understand well, the git-url-hash, if not a commit-hash, is first used as "SemVer" version constraints, then fallback as a branch/tag name. I suggest that we first try to match the git-url-hash against the tags and branches. |
@Volune, there is no documentation, the code evolved trying to satisfy the use cases that Yarn faced, we call this "self documenting code" :) Feel free to explore this code, we can afford making a breaking change here if it is justified. |
So what priority of these references would you set up: (none) master => #tag => #branch => #git-hash? What hash should go to the lockfile? |
I think we should still keep the git sha1 in the lockfile. This way we keep the deterministic property when using branches. For the resolution priority, I'd suggest as @Volune: |
I tested a little on NPM5, it doesn't seem to use the "SemVer" algorithm on tags. I think we should always keep the git sha1 in the lockfile (or the tarball hash, I saw another discussion about that). The tag is only supposed to be immutable, it can still be messed with. In my opinion, using sometimes the sha1 sometimes the full tag would be both more complex and less secure. Also I've seen some repositories not using No version
With version
|
Sounds good, @Volune. |
Working on it. Looking at the code made me realise there are a lot of things unclear regarding git dependencies, like some optimisations are not shared between git resolvers and git fetchers, or that dependencies using "github:", "bitbucket:" ... prefixes will not have their |
**Summary** For git dependencies, the branch/tag resolution does not always work as expected. Refactor the code to make the resolution algorithm more explicit and follow discussions in #3720. **Test plan** New test in `__tests__/util/git-ref-resolver.js`. Also, benefit from the fact that Travis CI ran the test with an older Git version. I don't know if we have a minimum git version requirement, it seems we currently don't test against any specific version. **Implementation details** I refactored `parseRefs` to return the full ref name, so we can differentiate branches and tags. I use `git ls-remote --symref` to get the default branch name. This works only in recent versions of git (thanks Travis CI for reporting the issue), so I fall back to another algorithm if `--symref` is unavailable. I tried not to use the variable name `hash`, which is confusing between the git-url hash and the commit hash.
Do you want to request a feature or report a bug?
a bug
What is the current behavior?
We have a repository where we have a branch for the minor version (eg
1.1
) and then tag releases for patch versions in this branch (v1.1.0
,v1.1.1
, ...)I want to point a project the branch so I can have changes that are not released yet, if I put:
It actually resolves to the last patch release (eg:
v1.1.1
) instead of the tip of the branch.If the current behavior is a bug, please provide the steps to reproduce.
See above, an example is:
The resulting
yarn.lock
is:4fd4c17
is thev1.1.0
tagWhat is the expected behavior?
It is expected to resolve to the tip of the branch.
At the moment, I specify the commit in the
package.json
as a workaround but I can't useyarn upgrade
.Please mention your node.js, yarn and operating system version.
The text was updated successfully, but these errors were encountered: