Skip to content

Commit 09f800b

Browse files
committed
Fix import-flux2-assets.sh on MacOS
If a tool called "gsed" is available, use that one. If not, revert to "sed" - on MacOS, sed is bsd sed and it fails around line 155, on the "Hack for fixing typo in the docs" regex Signed-off-by: Kingdon B <[email protected]> (cherry picked from commit aabe011)
1 parent 6b4f4e8 commit 09f800b

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

hack/import-flux2-assets.sh

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ if [ -z "${GITHUB_USER:-}" ]; then
99
GITHUB_USER=fluxcdbot
1010
fi
1111

12+
if [ "$(command -v gsed)" ]; then
13+
SED=$(which gsed)
14+
else
15+
SED=$(which sed)
16+
fi
17+
1218
if [ ! "$(command -v jq)" ]; then
1319
echo "Please install 'jq'."
1420
exit 1
@@ -77,9 +83,9 @@ gen_crd_doc() {
7783

7884
FIRST_LINE="$(grep -vEm1 "^<!--" "$TMP")"
7985
if echo "$FIRST_LINE" | grep -q "<h1>" ; then
80-
TITLE="$(echo "$FIRST_LINE" | cut -d'<' -f2 | cut -d'>' -f2 | sed 's/^\#\ //')"
86+
TITLE="$(echo "$FIRST_LINE" | cut -d'<' -f2 | cut -d'>' -f2 | $SED 's/^\#\ //')"
8187
elif echo "$FIRST_LINE" | grep -E "^# "; then
82-
TITLE="$(echo "$FIRST_LINE" | sed 's/^\#\ //')"
88+
TITLE="$(echo "$FIRST_LINE" | $SED 's/^\#\ //')"
8389
else
8490
echo "Don't know what to do with '$FIRST_LINE' in $TMP."
8591
exit 1
@@ -102,7 +108,7 @@ gen_crd_doc() {
102108
echo "weight: $WEIGHT"
103109
echo "---"
104110
} >> "$DEST"
105-
grep -vE "^<!--" "$TMP" |sed '1d' >> "$DEST"
111+
grep -vE "^<!--" "$TMP" |$SED '1d' >> "$DEST"
106112
rm "$TMP"
107113
else
108114
mv "$TMP" "$DEST"
@@ -152,10 +158,10 @@ function gen_ctrl_docs {
152158
gen_crd_doc "https://raw.githubusercontent.com/fluxcd/${ctrl}/${ctrl_version}/docs/spec/v1beta2/events.md" "$COMPONENTS_DIR/${ctrl_out}/events.md"
153159

154160
# Hack for fixing typo in the docs
155-
sed -i \
161+
$SED -i \
156162
's#((https://docs\.github\.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token))#(https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token)#g' \
157163
"$COMPONENTS_DIR/${ctrl_out}/providers.md"
158-
sed -i \
164+
$SED -i \
159165
's#((https://docs\.github\.com/en/apps/creating-github-apps/authenticating-with-a-github-app/authenticating-as-a-github-app-installation))#(https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/authenticating-as-a-github-app-installation)#g' \
160166
"$COMPONENTS_DIR/${ctrl_out}/providers.md"
161167
fi

0 commit comments

Comments
 (0)