mirror of
https://github.com/pnpm/pnpm.git
synced 2026-04-27 18:46:18 -04:00
fix: gitBranchLockfile/mergeGitBranchLockfilesBranchPattern set in workspace file (#10139)
close #9651
This commit is contained in:
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).
|
||||
@@ -287,24 +287,6 @@ export async function getConfig (opts: {
|
||||
if (typeof pnpmConfig.packageLock === 'boolean') return pnpmConfig.packageLock
|
||||
return false
|
||||
})()
|
||||
// NOTE: this block of code in this location is pointless.
|
||||
// TODO: move this block of code to after the code that loads pnpm-workspace.yaml.
|
||||
// TODO: unskip test `getConfig() sets mergeGiBranchLockfiles when branch matches mergeGitBranchLockfilesBranchPattern`.
|
||||
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) {
|
||||
@@ -414,6 +396,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
|
||||
})()
|
||||
|
||||
// omit some schema that the custom parser can't yet handle
|
||||
const envPnpmTypes = omit([
|
||||
'init-version', // the type is a private function named 'semver'
|
||||
|
||||
@@ -3,3 +3,4 @@ onlyBuiltDependencies:
|
||||
- foo
|
||||
sharedWorkspaceLockfile: false
|
||||
shamefullyHoist: true
|
||||
gitBranchLockfile: true
|
||||
|
||||
@@ -981,9 +981,7 @@ test('getConfig() should read cafile', async () => {
|
||||
-----END CERTIFICATE-----`])
|
||||
})
|
||||
|
||||
// NOTE: new bug detected: it doesn't work with pnpm-workspace.yaml
|
||||
// TODO: fix it later
|
||||
test.skip('respect mergeGitBranchLockfilesBranchPattern', async () => {
|
||||
test('respect mergeGitBranchLockfilesBranchPattern', async () => {
|
||||
{
|
||||
prepareEmpty()
|
||||
const { config } = await getConfig({
|
||||
@@ -1020,9 +1018,7 @@ test.skip('respect mergeGitBranchLockfilesBranchPattern', async () => {
|
||||
}
|
||||
})
|
||||
|
||||
// NOTE: new bug detected: it doesn't work with pnpm-workspace.yaml
|
||||
// TODO: fix it later
|
||||
test.skip('getConfig() sets mergeGitBranchLockfiles when branch matches mergeGitBranchLockfilesBranchPattern', async () => {
|
||||
test('getConfig() sets mergeGitBranchLockfiles when branch matches mergeGitBranchLockfilesBranchPattern', async () => {
|
||||
prepareEmpty()
|
||||
{
|
||||
writeYamlFile('pnpm-workspace.yaml', {
|
||||
@@ -1236,6 +1232,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