mirror of
https://github.com/pnpm/pnpm.git
synced 2026-01-15 02:18:31 -05:00
fix: gitBranchLockfile/mergeGitBranchLockfilesBranchPattern set in workspace file (#10139)
close #9651
This commit is contained in:
committed by
Zoltan Kochan
parent
17344ca27f
commit
36eb104e99
6
.changeset/witty-tigers-tell.md
Normal file
6
.changeset/witty-tigers-tell.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@pnpm/config": patch
|
||||
"pnpm": patch
|
||||
---
|
||||
|
||||
Setting `gitBranchLockfile` and related settings via `pnpm-workspace.yaml` should work [#9651](https://github.com/pnpm/pnpm/issues/9651).
|
||||
@@ -279,21 +279,6 @@ export async function getConfig (opts: {
|
||||
if (typeof pnpmConfig.packageLock === 'boolean') return pnpmConfig.packageLock
|
||||
return false
|
||||
})()
|
||||
pnpmConfig.useGitBranchLockfile = (() => {
|
||||
if (typeof pnpmConfig.gitBranchLockfile === 'boolean') return pnpmConfig.gitBranchLockfile
|
||||
return false
|
||||
})()
|
||||
pnpmConfig.mergeGitBranchLockfiles = await (async () => {
|
||||
if (typeof pnpmConfig.mergeGitBranchLockfiles === 'boolean') return pnpmConfig.mergeGitBranchLockfiles
|
||||
if (pnpmConfig.mergeGitBranchLockfilesBranchPattern != null && pnpmConfig.mergeGitBranchLockfilesBranchPattern.length > 0) {
|
||||
const branch = await getCurrentBranch()
|
||||
if (branch) {
|
||||
const branchMatcher = createMatcher(pnpmConfig.mergeGitBranchLockfilesBranchPattern)
|
||||
return branchMatcher(branch)
|
||||
}
|
||||
}
|
||||
return undefined
|
||||
})()
|
||||
pnpmConfig.pnpmHomeDir = getDataDir(process)
|
||||
let globalDirRoot
|
||||
if (pnpmConfig.globalDir) {
|
||||
@@ -396,6 +381,22 @@ export async function getConfig (opts: {
|
||||
}
|
||||
}
|
||||
|
||||
pnpmConfig.useGitBranchLockfile = (() => {
|
||||
if (typeof pnpmConfig.gitBranchLockfile === 'boolean') return pnpmConfig.gitBranchLockfile
|
||||
return false
|
||||
})()
|
||||
pnpmConfig.mergeGitBranchLockfiles = await (async () => {
|
||||
if (typeof pnpmConfig.mergeGitBranchLockfiles === 'boolean') return pnpmConfig.mergeGitBranchLockfiles
|
||||
if (pnpmConfig.mergeGitBranchLockfilesBranchPattern != null && pnpmConfig.mergeGitBranchLockfilesBranchPattern.length > 0) {
|
||||
const branch = await getCurrentBranch()
|
||||
if (branch) {
|
||||
const branchMatcher = createMatcher(pnpmConfig.mergeGitBranchLockfilesBranchPattern)
|
||||
return branchMatcher(branch)
|
||||
}
|
||||
}
|
||||
return undefined
|
||||
})()
|
||||
|
||||
overrideSupportedArchitecturesWithCLI(pnpmConfig, cliOptions)
|
||||
|
||||
if (opts.cliOptions['global']) {
|
||||
|
||||
@@ -3,3 +3,4 @@ onlyBuiltDependencies:
|
||||
- foo
|
||||
sharedWorkspaceLockfile: false
|
||||
shamefullyHoist: true
|
||||
gitBranchLockfile: true
|
||||
|
||||
@@ -842,7 +842,7 @@ test('getConfig() should read cafile', async () => {
|
||||
-----END CERTIFICATE-----`])
|
||||
})
|
||||
|
||||
test('respect merge-git-branch-lockfiles-branch-pattern', async () => {
|
||||
test('respect mergeGitBranchLockfilesBranchPattern', async () => {
|
||||
{
|
||||
const { config } = await getConfig({
|
||||
cliOptions: {},
|
||||
@@ -879,7 +879,7 @@ test('respect merge-git-branch-lockfiles-branch-pattern', async () => {
|
||||
}
|
||||
})
|
||||
|
||||
test('getConfig() sets merge-git-branch-lockfiles when branch matches merge-git-branch-lockfiles-branch-pattern', async () => {
|
||||
test('getConfig() sets mergeGitBranchLockfiles when branch matches mergeGitBranchLockfilesBranchPattern', async () => {
|
||||
prepareEmpty()
|
||||
{
|
||||
const npmrc = [
|
||||
@@ -1093,6 +1093,23 @@ test('settings shamefullyHoist in pnpm-workspace.yaml should take effect', async
|
||||
expect(config.rawConfig['shamefully-hoist']).toBe(true)
|
||||
})
|
||||
|
||||
test('settings gitBranchLockfile in pnpm-workspace.yaml should take effect', async () => {
|
||||
const workspaceDir = f.find('settings-in-workspace-yaml')
|
||||
process.chdir(workspaceDir)
|
||||
const { config } = await getConfig({
|
||||
cliOptions: {},
|
||||
workspaceDir,
|
||||
packageManager: {
|
||||
name: 'pnpm',
|
||||
version: '1.0.0',
|
||||
},
|
||||
})
|
||||
|
||||
expect(config.gitBranchLockfile).toBe(true)
|
||||
expect(config.useGitBranchLockfile).toBe(true)
|
||||
expect(config.rawConfig['git-branch-lockfile']).toBe(true)
|
||||
})
|
||||
|
||||
test('when dangerouslyAllowAllBuilds is set to true neverBuiltDependencies is set to an empty array', async () => {
|
||||
const { config } = await getConfig({
|
||||
cliOptions: {
|
||||
|
||||
Reference in New Issue
Block a user