Skip to content

Commit c104537

Browse files
committed
Set primary-site-*-url attrs when multiple sources
Previously the partial-build-extension did not set the primary-site-*-url attributes when there were multiple sources. This prevented the atlas plugin from running when there were multiple sources. This fix ensures that the primary-site-*-url attributes are now set.
1 parent 4f9b70c commit c104537

File tree

2 files changed

+52
-10
lines changed

2 files changed

+52
-10
lines changed

lib/partial-build-extension.js

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,25 @@ module.exports.register = function ({ config = {} }) {
4646
return
4747
}
4848
const sourcesLength = playbook.content.sources.length
49-
if (sourcesLength !== 1) {
49+
if (sourcesLength === 1) {
50+
Object.assign(
51+
playbook.content.sources[0],
52+
isBranch
53+
? {
54+
branches: [refname],
55+
tags: [],
56+
}
57+
: {
58+
branches: [],
59+
tags: [refname],
60+
}
61+
)
62+
if (isAuthorMode) {
63+
const authorUrl = resolveAuthorUrl(playbook.dir)
64+
Object.assign(playbook.content.sources[0], { url: authorUrl })
65+
}
66+
} else {
5067
console.log(`sources.length = ${sourcesLength} so deferring filtering till contentAggregated`)
51-
return
52-
}
53-
Object.assign(
54-
playbook.content.sources[0],
55-
isBranch ? { branches: [refname], tags: [] } : { branches: [], tags: [refname] }
56-
)
57-
if (isAuthorMode) {
58-
const authorUrl = resolveAuthorUrl(playbook.dir)
59-
Object.assign(playbook.content.sources[0], { url: authorUrl })
6068
}
6169
Object.assign(asciidocAttrs, { 'primary-site-url': '.', 'primary-site-manifest-url': siteManifestUrl })
6270
this.updateVariables({ playbook })

test/partial-build-extension-test.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,40 @@ describe('partial-build-extension', () => {
449449
'https://raw.githubusercontent.com/org/repo/6.0.0/gradle.properties',
450450
])
451451
})
452+
453+
it('multiple sources defaults primary-site-url and primary-site-manifest-url', async () => {
454+
playbook.dir = WORK_DIR
455+
playbook.site.url = httpServerUrl
456+
playbook.content.sources = [
457+
{
458+
url: '.',
459+
branches: ['main'],
460+
startPaths: ['new-start-path'],
461+
},
462+
{
463+
url: '.',
464+
branches: ['1.0.x'],
465+
startPaths: ['old-start-path'],
466+
},
467+
]
468+
ext.register.call(generatorContext, { config: { refname: 'HEAD', version: '7.0.0-SNAPSHOT' } })
469+
generatorContext.updateVariables({ playbook })
470+
await generatorContext.playbookBuilt(generatorContext.variables)
471+
expect(playbook.content.sources).to.eql([
472+
{
473+
url: '.',
474+
branches: ['main'],
475+
startPaths: ['new-start-path'],
476+
},
477+
{
478+
url: '.',
479+
branches: ['1.0.x'],
480+
startPaths: ['old-start-path'],
481+
},
482+
])
483+
expect(playbook.asciidoc.attributes['primary-site-manifest-url']).to.eql(`${httpServerUrl}/site-manifest.json`)
484+
expect(playbook.asciidoc.attributes['primary-site-url']).to.eql('.')
485+
})
452486
})
453487
})
454488
})

0 commit comments

Comments
 (0)