Skip to content

Commit e9ee611

Browse files
committed
partial-build-extension works for git dir of grandchildren
Previously, if the playbook is in a grandchild dir it incorrectly resolves the dir of ./.. because the regex was invalid This ensures that playbooks in folders that are grandchildren of the gitdir still work Closes gh-35
1 parent 4d2c208 commit e9ee611

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lib/partial-build-extension.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ function resolveAuthorUrl (dir) {
122122
return '.'
123123
}
124124
const relpath = ospath.relative(gitRoot, dir)
125-
const segments = (relpath.match(/path.sep/g) || []).length + 1
125+
const segments = [...relpath].filter((c) => c === ospath.sep).length + 1
126126
return '.' + '/..'.repeat(segments)
127127
}
128128

test/partial-build-extension-test.js

+12
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,18 @@ describe('partial-build-extension', () => {
181181
})
182182
})
183183

184+
it('should rewrite content sources if refname is HEAD and playbook in grandchild dir', async () => {
185+
const playBookDir = ospath.join(WORK_DIR, 'docs/src/main/antora')
186+
await fsp.mkdir(playBookDir, { recursive: true })
187+
await fsp.mkdir(ospath.join(WORK_DIR, '.git'), { recursive: true })
188+
await runScenario({
189+
refname: 'HEAD',
190+
version: '6.1.0-SNAPSHOT',
191+
expectedRefs: { branches: ['HEAD'], tags: [], url: './../../../..' },
192+
playbookDir: playBookDir,
193+
})
194+
})
195+
184196
it('should rewrite content sources when SNAPSHOT version not found if refname is HEAD', async () => {
185197
const playBookDir = WORK_DIR
186198
await fsp.mkdir(ospath.join(WORK_DIR, '.git'), { recursive: true })

0 commit comments

Comments
 (0)