Skip to content

Commit 6f550b6

Browse files
committed
build_antora.sh: restore BRANCH
1 parent 867dd0a commit 6f550b6

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

doc/build_antora.sh

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# Official REPOSITORY: https://github.com/boostorg/openmethod
1010
#
1111

12-
set -e
12+
set -ex
1313

1414
if [ $# -eq 0 ]
1515
then
@@ -39,11 +39,14 @@ if [ -z "${BOOST_SRC_DIR:-}" ]; then
3939
fi
4040
fi
4141

42+
BRANCH=master
43+
4244
if [ -n "${BOOST_SRC_DIR:-}" ]; then
4345
if [ -n "${CIRCLE_REPOSITORY_URL:-}" ]; then
4446
if [[ "$CIRCLE_REPOSITORY_URL" =~ boostorg/boost(\.git)?$ ]]; then
4547
LIB="$(basename "$(dirname "$SCRIPT_DIR")")"
4648
REPOSITORY="boostorg/${LIB}"
49+
BRANCH=$(git -C "$BOOST_SRC_DIR" rev-parse --abbrev-ref HEAD)
4750
else
4851
ACCOUNT="${CIRCLE_REPOSITORY_URL#*:}"
4952
ACCOUNT="${ACCOUNT%%/*}"
@@ -60,10 +63,10 @@ fi
6063
cd "$SCRIPT_DIR"
6164

6265
if [ -n "${REPOSITORY}" ] && [ -n "${SHA}" ]; then
63-
base_url="https://github.com/${REPOSITORY}/blob/${SHA}"
64-
echo "Setting base-url to $base_url"
66+
BASE_URL="https://github.com/${REPOSITORY}/blob/${SHA}"
67+
echo "Setting base-url to $BASE_URL"
6568
cp mrdocs.yml mrdocs.yml.bak
66-
perl -i -pe 's{^\s*base-url:.*$}{base-url: '"$base_url/"'}' mrdocs.yml
69+
perl -i -pe 's{^\s*base-url:.*$}{base-url: '"$BASE_URL/"'}' mrdocs.yml
6770
else
6871
echo "REPOSITORY or SHA not set; skipping base-url modification"
6972
fi
@@ -78,22 +81,24 @@ export PATH
7881
npx antora --clean --fetch "$PLAYBOOK" --stacktrace # --log-level all
7982

8083
echo "Fixing links to non-mrdocs URIs..."
84+
echo "BRANCH='${BRANCH:-}'"
85+
echo "BASE_URL='${BASE_URL:-}'"
8186

8287
for f in $(find html -name '*.html'); do
83-
perl -i -pe 's{&lcub;&lcub;(.*?)&rcub;&rcub;}{<a href="../../../$1.html">$1</a>}g' "$f"
84-
perl -i -pe 's{<a href="motivation.html">Boost.OpenMethod</a>}{<a href="https://www.boost.org/library/${BRANCH}/openmethod/">Boost.OpenMethod</a>}g' "$f"
88+
perl -i -pe "s{&lcub;&lcub;(.*?)&rcub;&rcub;}{<a href=\"../../../\$1.html\">\$1</a>}g" "$f"
89+
perl -i -pe "s{<a href=\"motivation.html\">Boost.OpenMethod</a>}{<a href=\"https://www.boost.org/library/${BRANCH}/openmethod/\">Boost.OpenMethod</a>}g" "$f"
8590
done
8691

92+
BASE_URL=test
8793

88-
89-
if [ -n "${base_url:-}" ]; then
94+
if [ -n "${BASE_URL:-}" ]; then
9095
if [ -f mrdocs.yml.bak ]; then
9196
mv -f mrdocs.yml.bak mrdocs.yml
9297
echo "Restored original mrdocs.yml"
9398
else
9499
echo "mrdocs.yml.bak not found; skipping restore"
95100
fi
96-
perl -i -pe "s[{{BASE_URL}}][$base_url]g" \
101+
perl -i -pe "s[{{BASE_URL}}][$BASE_URL]g" \
97102
html/openmethod/ref_headers.html html/openmethod/BOOST_OPENMETHOD*.html
98103
fi
99104

0 commit comments

Comments
 (0)