-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
feat: add git-branch-lockfile config to generate lockfile in each branch #4475
Conversation
Thanks for working on this! |
As far as I understand from your changes, the branch lockfiles are completely ignored. They are just removed. What we need instead is something like a I mean this field: Line 3579 in bc35dff
|
Updates:
Yes
After a second thought, i think it's essential to merge something into the main lockfile( Assuming there are multiple lockfiles,
For
It seems conflicts doesn't a big issue when merging
I will refactor |
I think order doesn't matter (sort the branches alphabetically). The only thing that matters is that you merge the branch lockfiles into the main lockfile. So the entries in the branch lockfiles should have bigger priority than the ones in the main lockfile. |
Updates:
Q: I wonder why sort the branches when the order doesn't matter? |
To make it deterministic. |
Got it. For now, i don't sort everything. but i think eventually the keys of the |
What will happen if I rebase my branch from the main branch? Should I regenerate my branch lockfile? |
I would like to write down the whole workflow from a user perspective. When
Note: When In a nutshell, every lockfile changes are applied to the branch lockfile.
Note: For now, there is no differences between the default branch and the feature branches. In a nutshell, no magic in the git default branch. I thought about other designs:
Pros:
Cons:
When Pros:
Cons:
|
I think you nailed the design, but that's just me! Being dependent on git for this feature is perhaps unfortunate to some but I think we can afford to be opinionated here as the original problem is with regards to git merge conflicts. |
Hey @wbern , thank you to push this issue move forward. Since we are targeting git merge conflicts, the solution depends on git seems reasonable :) |
This should happen only if there were changes to the lockfile.
I don't get it, so you'll have to remember to always run |
pnpmConfig.useGitBranchLockfile = (() => { | ||
if (typeof pnpmConfig['gitBranchLockfile'] === 'boolean') return pnpmConfig['gitBranchLockfile'] | ||
return false | ||
})() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed? The default value of use-git-branch-lockfile
is set to false
at line 184
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (opts.mergeGitBranchLockfiles) { | ||
result.lockfile = await _mergeGitBranchLockfiles(result.lockfile, pkgPath, pkgPath, opts) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be inside the loop?
}) | ||
}) | ||
|
||
test('readWantedLockfile() when useGitBranchLockfile and mergeGitBranchLockfiles', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a scenario in which useGitBranchLockfile is false and mergeGitBranchLockfiles is true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could happen. The behavior is same as useGitBranchLockfile = true
and mergeGitBranchLockfiles = true
. That means useGitBranchLockfile
is of no use when mergeGitBranchLockfiles = true
pnpm-lock.yaml
Outdated
@@ -8278,7 +8295,7 @@ packages: | |||
resolution: {integrity: sha512-oUwtPJ1W0SKD0Tr+wqu92c5xuCeQqB3hSCHasn/ZgjFdA9iDGNkNf2Zi9ztY7X+hNuMib23LNGRm6+uN+KLE3g==} | |||
engines: {node: '>=8.10.0'} | |||
peerDependencies: | |||
eslint: '*' | |||
eslint: '>=5.16.0 || *' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update your pnpm version. You are not using the latest v6, that is why the lockfile gets changed like this.
This is a big change, so I recommend you to publish a version from this branch and try it in your team. Gather feedback to see if it works for you. |
This make sense. Is it possible to publish an alpha version officially? |
🚢 pnpm@7.0.0-pr4475.0 |
@zkochan FYI, running It probably also means that a future I don't know what a good solution is, though. |
This is confusing indeed. Maybe we need to change how canary versions are installed and disallow installing them by range. So |
Hmmm, that seems like it would break expectations. Because I would want to get newer pre-release versions of a package if I use Maybe we could change the naming of test releases like this one? So we could name it something like |
da14d53
to
7f307b4
Compare
Hey @chengcyber I just realized that we don't have any information about this in the docs. Even the settings are not documented. We need to add a new page about this feature and describe how to use it. |
Hi @zkochan, you are right. I created a PR to add documents for this feature at pnpm/pnpm.io#455 |
vercel can't detect the file Now specific issue is:
So I ended up got the error in vercel:
One way to solve this is to delete
Is there any better solution for this? |
Summary
Ref #4324
Detail
git-branch-lockfile
specified.npmrc
to turn on lockfile assembly feature.pnpm install
will updatepnpm-lock.<branch_name>.yaml
instead ofpnpm-lock.yaml
, this helps avoiding PR conflicts on a singlepnpm-lock.yaml
file.--merge-git-branch-lockfiles
forpnpm install
. After PR merged into the main branch, runpnpm install --merge-git-branch-lockfiles
to update the main lockfile and remove the others.How to test it
Unit tests are added to test this feature, including
gitBranchLockfile
&mergeGitBranchLockfiles