@antora/content-aggregator 3.1.13 → 3.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/aggregate-content.js +17 -18
- package/lib/filter-refs.js +5 -0
- package/package.json +2 -2
package/lib/aggregate-content.js
CHANGED
|
@@ -87,8 +87,8 @@ const URL_PORT_CLEANER_RX = /^([^/]+):[0-9]+(?=\/)/
|
|
|
87
87
|
*/
|
|
88
88
|
function aggregateContent (playbook) {
|
|
89
89
|
const startDir = playbook.dir || '.'
|
|
90
|
-
const { branches, editUrl, tags, sources } = playbook.content
|
|
91
|
-
const sourceDefaults = { branches, editUrl, tags }
|
|
90
|
+
const { branches, editUrl, tags, sources, worktrees } = playbook.content
|
|
91
|
+
const sourceDefaults = { branches, editUrl, tags, worktrees }
|
|
92
92
|
const { cacheDir: requestedCacheDir, fetch, quiet } = playbook.runtime
|
|
93
93
|
return ensureCacheDir(requestedCacheDir, startDir).then((cacheDir) => {
|
|
94
94
|
const gitConfig = Object.assign({ ensureGitSuffix: true }, playbook.git)
|
|
@@ -285,7 +285,7 @@ async function selectStartPathsForRepository (repo, authStatus, sources) {
|
|
|
285
285
|
|
|
286
286
|
// QUESTION should we resolve HEAD to a ref eagerly to avoid having to do a match on it?
|
|
287
287
|
async function selectReferences (source, repo, remote) {
|
|
288
|
-
let { branches: branchPatterns, tags: tagPatterns, worktrees: worktreePatterns
|
|
288
|
+
let { branches: branchPatterns, tags: tagPatterns, worktrees: worktreePatterns } = source
|
|
289
289
|
const managed = 'url' in repo
|
|
290
290
|
const isBare = managed || repo.noCheckout
|
|
291
291
|
const patternCache = repo.cache[REF_PATTERN_CACHE_KEY]
|
|
@@ -306,15 +306,19 @@ async function selectReferences (source, repo, remote) {
|
|
|
306
306
|
}
|
|
307
307
|
}
|
|
308
308
|
if (!branchPatterns) return [...refs.values()]
|
|
309
|
+
let usePrimaryWorktree
|
|
309
310
|
if (worktreePatterns) {
|
|
310
311
|
if (worktreePatterns === '.') {
|
|
311
|
-
worktreePatterns = [
|
|
312
|
+
worktreePatterns = (usePrimaryWorktree = true) && []
|
|
312
313
|
} else if (worktreePatterns === true) {
|
|
313
|
-
worktreePatterns = ['
|
|
314
|
+
worktreePatterns = (usePrimaryWorktree = true) && ['*']
|
|
314
315
|
} else {
|
|
315
316
|
worktreePatterns = Array.isArray(worktreePatterns)
|
|
316
317
|
? worktreePatterns.map((pattern) => String(pattern))
|
|
317
318
|
: splitRefPatterns(String(worktreePatterns))
|
|
319
|
+
if (~worktreePatterns.indexOf('.')) {
|
|
320
|
+
worktreePatterns = (usePrimaryWorktree = true) && worktreePatterns.filter((it) => it !== '.')
|
|
321
|
+
}
|
|
318
322
|
}
|
|
319
323
|
} else {
|
|
320
324
|
worktreePatterns = []
|
|
@@ -328,7 +332,7 @@ async function selectReferences (source, repo, remote) {
|
|
|
328
332
|
return [...refs.values()]
|
|
329
333
|
} else {
|
|
330
334
|
// NOTE current branch is undefined when HEAD is detached
|
|
331
|
-
const head =
|
|
335
|
+
const head = usePrimaryWorktree ? repo.dir : noWorktree
|
|
332
336
|
refs.set('HEAD', { shortname: 'HEAD', fullname: 'HEAD', type: 'branch', detached: true, head })
|
|
333
337
|
return [...refs.values()]
|
|
334
338
|
}
|
|
@@ -351,11 +355,7 @@ async function selectReferences (source, repo, remote) {
|
|
|
351
355
|
} else if (isBare) {
|
|
352
356
|
branchPatterns.splice(headBranchIdx, 1)
|
|
353
357
|
} else {
|
|
354
|
-
|
|
355
|
-
if (worktreePatterns[0] === '.') {
|
|
356
|
-
worktreePatterns = worktreePatterns.slice(1)
|
|
357
|
-
head = repo.dir
|
|
358
|
-
}
|
|
358
|
+
const head = usePrimaryWorktree ? repo.dir : noWorktree
|
|
359
359
|
// NOTE current branch is undefined when HEAD is detached
|
|
360
360
|
refs.set('HEAD', { shortname: 'HEAD', fullname: 'HEAD', type: 'branch', detached: true, head })
|
|
361
361
|
branchPatterns.splice(headBranchIdx, 1)
|
|
@@ -378,7 +378,7 @@ async function selectReferences (source, repo, remote) {
|
|
|
378
378
|
if (!isBare) {
|
|
379
379
|
const localBranches = await git.listBranches(repo)
|
|
380
380
|
if (localBranches.length) {
|
|
381
|
-
const worktrees = await findWorktrees(repo, worktreePatterns)
|
|
381
|
+
const worktrees = await findWorktrees(repo, worktreePatterns, usePrimaryWorktree)
|
|
382
382
|
for (const shortname of filterRefs(localBranches, branchPatterns, patternCache)) {
|
|
383
383
|
const head = worktrees.get(shortname) || noWorktree
|
|
384
384
|
refs.set(shortname, { shortname, fullname: 'heads/' + shortname, type: 'branch', head })
|
|
@@ -1029,9 +1029,8 @@ function coerceToString (value) {
|
|
|
1029
1029
|
return value == null ? '' : String(value)
|
|
1030
1030
|
}
|
|
1031
1031
|
|
|
1032
|
-
function findWorktrees (repo, patterns) {
|
|
1033
|
-
if (!patterns.length) return new Map()
|
|
1034
|
-
const linkedOnly = patterns[0] === '.' ? !(patterns = patterns.slice(1)) : true
|
|
1032
|
+
function findWorktrees (repo, patterns, usePrimaryWorktree) {
|
|
1033
|
+
if (!(usePrimaryWorktree || patterns.length)) return new Map()
|
|
1035
1034
|
let worktreesDir
|
|
1036
1035
|
const patternCache = repo.cache[REF_PATTERN_CACHE_KEY]
|
|
1037
1036
|
return (
|
|
@@ -1058,9 +1057,9 @@ function findWorktrees (repo, patterns) {
|
|
|
1058
1057
|
)
|
|
1059
1058
|
: Promise.resolve(new Map())
|
|
1060
1059
|
).then((worktrees) =>
|
|
1061
|
-
|
|
1062
|
-
? worktrees
|
|
1063
|
-
:
|
|
1060
|
+
usePrimaryWorktree
|
|
1061
|
+
? git.currentBranch(repo).then((branch) => (branch ? worktrees.set(branch, repo.dir) : worktrees))
|
|
1062
|
+
: worktrees
|
|
1064
1063
|
)
|
|
1065
1064
|
}
|
|
1066
1065
|
|
package/lib/filter-refs.js
CHANGED
|
@@ -31,6 +31,7 @@ function createMatcher (patterns, cache = Object.assign(new Map(), { braces: new
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
function filterRefs (candidates, patterns, cache) {
|
|
34
|
+
if (!(patterns = patterns.filter(compact)).length) return []
|
|
34
35
|
const isMatch = createMatcher(patterns, cache)
|
|
35
36
|
return candidates.reduce((accum, candidate) => {
|
|
36
37
|
if (isMatch(candidate)) accum.push(candidate)
|
|
@@ -38,4 +39,8 @@ function filterRefs (candidates, patterns, cache) {
|
|
|
38
39
|
}, [])
|
|
39
40
|
}
|
|
40
41
|
|
|
42
|
+
function compact (str) {
|
|
43
|
+
return str !== ''
|
|
44
|
+
}
|
|
45
|
+
|
|
41
46
|
module.exports = filterRefs
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antora/content-aggregator",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.14",
|
|
4
4
|
"description": "Fetches and aggregates content from distributed sources for use in an Antora documentation pipeline.",
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
6
|
"author": "OpenDevise Inc. (https://opendevise.com)",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@antora/expand-path-helper": "~3.0",
|
|
35
|
-
"@antora/logger": "3.1.
|
|
35
|
+
"@antora/logger": "3.1.14",
|
|
36
36
|
"@antora/user-require-helper": "~3.0",
|
|
37
37
|
"braces": "~3.0",
|
|
38
38
|
"cache-directory": "~2.0",
|