mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-07-07 19:22:14 +00:00
add Antora playbook that is configured to use worktrees
This commit is contained in:
parent
a3024326a3
commit
ba7a6d1c64
35
antora-playbook-with-worktrees.yml
Normal file
35
antora-playbook-with-worktrees.yml
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
antora:
|
||||||
|
extensions:
|
||||||
|
- ./lib/antora/extensions/antora-linked-worktree-patch.js
|
||||||
|
- ./lib/antora/extensions/version-fix.js
|
||||||
|
- ./lib/antora/extensions/major-minor-segment.js
|
||||||
|
runtime:
|
||||||
|
log:
|
||||||
|
format: pretty
|
||||||
|
site:
|
||||||
|
title: Spring Security
|
||||||
|
url: https://docs.spring.io/spring-security/reference
|
||||||
|
robots: allow
|
||||||
|
git:
|
||||||
|
ensure_git_suffix: false
|
||||||
|
content:
|
||||||
|
sources:
|
||||||
|
- url: https://github.com/spring-io/spring-generated-docs
|
||||||
|
branches: 'spring-projects/spring-security/{main,5.{{6..9},{1..9}+({0..9})}.{x,+({0..9})}}'
|
||||||
|
- url: .
|
||||||
|
branches: '{main,5.{{6..9},{1..9}+({0..9})}.x}'
|
||||||
|
worktrees: true # will automatically discover worktrees if they are set up; otherwise, will use git tree
|
||||||
|
tags: '5.{{6..9},{1..9}+({0..9})}.+({0..9})'
|
||||||
|
start_path: docs
|
||||||
|
asciidoc:
|
||||||
|
attributes:
|
||||||
|
page-pagination: ''
|
||||||
|
hide-uri-scheme: '@'
|
||||||
|
urls:
|
||||||
|
latest_version_segment_strategy: redirect:to
|
||||||
|
latest_version_segment: ''
|
||||||
|
redirect_facility: httpd
|
||||||
|
ui:
|
||||||
|
bundle:
|
||||||
|
url: https://github.com/spring-io/antora-ui-spring/releases/download/latest/ui-bundle.zip
|
||||||
|
snapshot: true
|
53
lib/antora/extensions/antora-linked-worktree-patch.js
Normal file
53
lib/antora/extensions/antora-linked-worktree-patch.js
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
'use strict'
|
||||||
|
|
||||||
|
/* Copyright (c) 2002-2022 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
const { promises: fsp } = require('fs')
|
||||||
|
const ospath = require('path')
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rewrites local content sources to support the use of linked worktrees.
|
||||||
|
*
|
||||||
|
* @author Dan Allen <dan@opendevise.com>
|
||||||
|
*/
|
||||||
|
module.exports.register = function () {
|
||||||
|
this.once('playbookBuilt', async ({ playbook }) => {
|
||||||
|
const expandPath = this.require('@antora/expand-path-helper')
|
||||||
|
for (const contentSource of playbook.content.sources) {
|
||||||
|
const { url, branches } = contentSource
|
||||||
|
if (url.charAt() !== '.') continue
|
||||||
|
const absdir = expandPath(url, { dot: playbook.dir })
|
||||||
|
const gitfile = ospath.join(absdir, '.git')
|
||||||
|
if (await fsp.stat(gitfile).then((stat) => !stat.isDirectory(), () => false)) {
|
||||||
|
const worktreeGitdir = await fsp.readFile(gitfile, 'utf8')
|
||||||
|
.then((contents) => contents.trimRight().substr(8))
|
||||||
|
const worktreeBranch = await fsp.readFile(ospath.join(worktreeGitdir, 'HEAD'), 'utf8')
|
||||||
|
.then((contents) => contents.trimRight().replace(/^ref: (?:refs\/heads\/)?/, ''))
|
||||||
|
const reldir = ospath.relative(
|
||||||
|
playbook.dir,
|
||||||
|
await fsp.readFile(ospath.join(worktreeGitdir, 'commondir'), 'utf8')
|
||||||
|
.then((contents) => {
|
||||||
|
const gitdir = ospath.join(worktreeGitdir, contents.trimRight())
|
||||||
|
return ospath.basename(gitdir) === '.git' ? ospath.dirname(gitdir) : gitdir
|
||||||
|
})
|
||||||
|
)
|
||||||
|
contentSource.url = reldir ? `.${ospath.sep}${reldir}` : '.'
|
||||||
|
if (!branches) continue
|
||||||
|
contentSource.branches = (branches.constructor === Array ? branches : [branches])
|
||||||
|
.map((pattern) => pattern.replaceAll('HEAD', worktreeBranch))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user