mirror of
https://github.com/prdlk/leetcode.git
synced 2026-11-02 13:12:44 +00:00
ci(git): sync redirects in pre-commit hook
This commit is contained in:
1 parent
bfeadc0cdf
commit
f34a9bb56d
2 files changed
+11
-9
No files matched your search
@@ -1,8 +1,9 @@
|
||||
#!/bin/sh
|
||||
# Pre-commit: the docs pages under apps/docs/content are generated from work/1
|
||||
# by `bun run sync`, and deploy.yml publishes whatever main holds. Regenerate
|
||||
# them now and stage what sync changed, so a solution and its page land in the
|
||||
# same commit and a stale `## Solution` never reaches main.
|
||||
# Pre-commit: the docs pages under apps/docs/content (and the `/<num>` short
|
||||
# links in apps/docs/redirects.ts) are generated from work/1 by `bun run sync`,
|
||||
# and deploy.yml publishes whatever main holds. Regenerate them now and stage
|
||||
# what sync changed, so a solution, its page and its redirect land in the same
|
||||
# commit and a stale `## Solution` never reaches main.
|
||||
#
|
||||
# Sync reads the working tree, not the index, so the pages it writes only
|
||||
# match this commit when work/1 has nothing unstaged: an untracked or
|
||||
@@ -26,9 +27,9 @@ fi
|
||||
|
||||
before=$(mktemp)
|
||||
trap 'rm -f "$before"' EXIT
|
||||
git status --porcelain -- apps/docs/content | sort > "$before"
|
||||
git status --porcelain -- apps/docs/content apps/docs/redirects.ts | sort > "$before"
|
||||
report=$(bun run --silent sync)
|
||||
generated=$(git status --porcelain -- apps/docs/content | sort | comm -13 "$before" - | cut -c4-)
|
||||
generated=$(git status --porcelain -- apps/docs/content apps/docs/redirects.ts | sort | comm -13 "$before" - | cut -c4-)
|
||||
if [ -n "$generated" ]; then
|
||||
printf '%s\n' "$report" | grep -v 'skipped (in sync)' >&2
|
||||
printf '%s\n' "$generated" | xargs git add --
|
||||
|
||||
Reference in new issue
Block a user