Skip to content

Commit 2ad7e51

Browse files
committed
chore: Check secrets repo if out-of-date and make arrays cross-platform
1 parent 9305553 commit 2ad7e51

File tree

4 files changed

+24
-6
lines changed

4 files changed

+24
-6
lines changed

.husky/pre-commit

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
#!/usr/bin/env bash
1+
#!/usr/bin/env sh
22
. "$(dirname -- "$0")/_/husky.sh"
33

4-
read -ra TO_PRETTIFY <<< "$(git diff --diff-filter=ACMTUXB --name-only --staged | grep -E -e '\.[jt]sx?$' -e '\.md$' -e '\.html$' -e '\.json$' || :)"
5-
if (( ${#TO_PRETTIFY[@]} )); then npm run prettify "${TO_PRETTIFY[@]}"; fi
6-
npm test
7-
FAIL_ON_PENDING=true npm run notify-unpushed -- src/secrets
4+
bash <<EOF
5+
TO_PRETTIFY="$(git diff --diff-filter=ACMTUXB --name-only --staged | grep -E -e '\.[jt]sx?$' -e '\.md$' -e '\.html$' -e '\.json$' || :) )"
6+
if [[ -n "$TO_PRETTIFY" ]]; then npm run prettify $TO_PRETTIFY; fi
7+
npm test
8+
FAIL_ON_PENDING=true npm run notify-unpushed -- src/secrets
9+
npm run secrets-check
10+
EOF

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"build-configs": "bash ./scripts/build_nginx_confs.sh",
88
"lint": "eslint src --ext .ts",
99
"lint:fix": "eslint src --ext .ts --fix",
10-
"notify-unpushed": "sh ./scripts/notify-unpushed.sh",
10+
"notify-unpushed": "sh scripts/notify_unpushed.sh",
11+
"secrets-check": "sh scripts/secrets_check.sh",
1112
"prettify": "prettier -w",
1213
"prepare": "sh ./scripts/setup.sh",
1314
"servers": "npm run webpack-server & npm run tailwind-server",

scripts/secrets_check.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env sh
2+
3+
cd src/secrets || :
4+
REF=$(git rev-parse --abbrev-ref '@{u}')
5+
git fetch $(echo "$REF" | sed 's#/# #') --quiet
6+
REV=$(git rev-parse "$REF")
7+
8+
if git merge-base --is-ancestor "$REV" HEAD
9+
then
10+
echo 'Secrets branch up-to-date.'
11+
else
12+
echo "Your secrets repo is out-of-date with $REF. Please update it."
13+
exit 1
14+
fi

0 commit comments

Comments
 (0)