Rename script/fetch-policy to script/commit-current-upstream-policy-docs
check / check (push) Canceled after 0s
check / check (push) Canceled after 0s
sneak, on the PR: the script does more than fetch, and short names are not wanted. The make target, the test names, the variables and the messages take the new name. Behaviour is unchanged. Model: opus-5-5
This commit is contained in:
1 parent
917fe4bc1d
commit
ed60414378
9 files changed
+145
-129
No files matched your search
@@ -1,4 +1,4 @@
|
|||||||
.PHONY: bootstrap setup test lint fmt fmt-check check docker hooks fetch-policy update-policy
|
.PHONY: bootstrap setup test lint fmt fmt-check check docker hooks commit-current-upstream-policy-docs update-policy
|
||||||
|
|
||||||
# Makefile targets are thin shims; the implementations live in script/
|
# Makefile targets are thin shims; the implementations live in script/
|
||||||
# per the scripts-to-rule-them-all pattern (see the Entrypoints section
|
# per the scripts-to-rule-them-all pattern (see the Entrypoints section
|
||||||
@@ -31,8 +31,8 @@ docker:
|
|||||||
hooks:
|
hooks:
|
||||||
@script/install-precommit
|
@script/install-precommit
|
||||||
|
|
||||||
fetch-policy:
|
commit-current-upstream-policy-docs:
|
||||||
@script/fetch-policy
|
@script/commit-current-upstream-policy-docs
|
||||||
|
|
||||||
update-policy:
|
update-policy:
|
||||||
@script/update-policy
|
@script/update-policy
|
||||||
@@ -141,13 +141,14 @@ alpine. We provide:
|
|||||||
`script/check`
|
`script/check`
|
||||||
- `script/install-precommit` — installs the git pre-commit hook (our own
|
- `script/install-precommit` — installs the git pre-commit hook (our own
|
||||||
extension); `make hooks` shims to it
|
extension); `make hooks` shims to it
|
||||||
- `script/fetch-policy` — fetch the vendored policy files from this repo over
|
- `script/commit-current-upstream-policy-docs` — fetch the vendored policy files
|
||||||
HTTP and write them into a repo (our own extension). It writes into the repo
|
from this repo over HTTP and write them into a repo (our own extension). It
|
||||||
given as its argument, or its own repo with no argument. It stops when its
|
writes into the repo given as its argument, or its own repo with no argument.
|
||||||
target is this repo.
|
It stops when its target is this repo.
|
||||||
- `script/update-policy` — fetch the current `script/fetch-policy`, run it on
|
- `script/update-policy` — fetch the current
|
||||||
its own repo and commit the result without pushing (our own extension). It is
|
`script/commit-current-upstream-policy-docs`, run it on its own repo and
|
||||||
for the repos that vendor the policy files. It stops when run here.
|
commit the result without pushing (our own extension). It is for the repos
|
||||||
|
that vendor the policy files. It stops when run here.
|
||||||
|
|
||||||
`make hooks` installs the pre-commit hook that runs `script/precommit`.
|
`make hooks` installs the pre-commit hook that runs `script/precommit`.
|
||||||
|
|
||||||
|
|||||||
@@ -21,11 +21,12 @@ fmt-check, and commit.
|
|||||||
|
|
||||||
# Completed Steps
|
# Completed Steps
|
||||||
|
|
||||||
- 2026-11-09: `script/fetch-policy` writes the vendored policy files into a repo
|
- 2026-11-09: `script/commit-current-upstream-policy-docs` writes the vendored
|
||||||
over HTTP, itself and `script/update-policy` among them
|
policy files into a repo over HTTP, itself and `script/update-policy` among
|
||||||
(https://git.eeqj.de/sneak/prompts/issues/165). `make update-policy` now
|
them (https://git.eeqj.de/sneak/prompts/issues/165). `make update-policy` now
|
||||||
fetches the current `script/fetch-policy`, runs it and commits without
|
fetches the current `script/commit-current-upstream-policy-docs`, runs it and
|
||||||
pushing. The template repositories get both scripts in their own issues.
|
commits without pushing. The template repositories get both scripts in their
|
||||||
|
own issues.
|
||||||
- 2026-11-09: `script/update-policy` and `make update-policy` update a repo's
|
- 2026-11-09: `script/update-policy` and `make update-policy` update a repo's
|
||||||
vendored policy files with one command
|
vendored policy files with one command
|
||||||
(https://git.eeqj.de/sneak/prompts/issues/162). They fetch the files from
|
(https://git.eeqj.de/sneak/prompts/issues/162). They fetch the files from
|
||||||
|
|||||||
@@ -211,21 +211,22 @@ with your task.
|
|||||||
`https://git.eeqj.de/sneak/prompts/raw/branch/main/script/<name>`
|
`https://git.eeqj.de/sneak/prompts/raw/branch/main/script/<name>`
|
||||||
- [ ] `script/precommit` exists and the pre-commit hook (installed by
|
- [ ] `script/precommit` exists and the pre-commit hook (installed by
|
||||||
`script/install-precommit`, shimmed by `make hooks`) runs it
|
`script/install-precommit`, shimmed by `make hooks`) runs it
|
||||||
- [ ] `script/fetch-policy` and `script/update-policy` exist, identical to the
|
- [ ] `script/commit-current-upstream-policy-docs` and `script/update-policy`
|
||||||
model scripts, and `make update-policy` shims to `script/update-policy`.
|
exist, identical to the model scripts, and `make update-policy` shims to
|
||||||
`make update-policy` commits without pushing, so a person reviews and
|
`script/update-policy`. `make update-policy` commits without pushing, so a
|
||||||
pushes the commit. A `.gitignore` or `.dockerignore` without the comment
|
person reviews and pushes the commit. A `.gitignore` or `.dockerignore`
|
||||||
that ends the canonical file needs no preparation. The script moves each
|
without the comment that ends the canonical file needs no preparation. The
|
||||||
line the canonical file has never held to below the canonical content.
|
script moves each line the canonical file has never held to below the
|
||||||
Blank lines and comments are dropped. Before its first use, add that
|
canonical content. Blank lines and comments are dropped. Before its first
|
||||||
comment to an `.editorconfig` that has lines of its own, and put those
|
use, add that comment to an `.editorconfig` that has lines of its own, and
|
||||||
lines below it. Otherwise the script stops before it writes anything,
|
put those lines below it. Otherwise the script stops before it writes
|
||||||
naming the file and each line. In a file that has the comment, an entry
|
anything, naming the file and each line. In a file that has the comment,
|
||||||
above it which the canonical file has never held also stops the script. It
|
an entry above it which the canonical file has never held also stops the
|
||||||
stops the same way on a line in `.golangci.yml` that the canonical file
|
script. It stops the same way on a line in `.golangci.yml` that the
|
||||||
has never held, apart from comments and the repo's entries in the `deny`
|
canonical file has never held, apart from comments and the repo's entries
|
||||||
list of the `test-support` rule. It also stops on a repo's own
|
in the `deny` list of the `test-support` rule. It also stops on a repo's
|
||||||
`script/fetch-policy` or `script/update-policy`.
|
own `script/commit-current-upstream-policy-docs` or
|
||||||
|
`script/update-policy`.
|
||||||
- [ ] README has an **Entrypoints** section documenting the `script/`
|
- [ ] README has an **Entrypoints** section documenting the `script/`
|
||||||
entrypoints and linking the standard
|
entrypoints and linking the standard
|
||||||
- [ ] `script/lint` and `script/test` each run
|
- [ ] `script/lint` and `script/test` each run
|
||||||
|
|||||||
@@ -266,12 +266,12 @@ are thin shims calling them. Model scripts:
|
|||||||
- [ ] `script/install-precommit` — installs the pre-commit hook that runs
|
- [ ] `script/install-precommit` — installs the pre-commit hook that runs
|
||||||
`script/precommit`
|
`script/precommit`
|
||||||
- [ ] `make hooks` — shims to `script/install-precommit`
|
- [ ] `make hooks` — shims to `script/install-precommit`
|
||||||
- [ ] `script/fetch-policy` — fetches the vendored policy files from the
|
- [ ] `script/commit-current-upstream-policy-docs` — fetches the vendored policy
|
||||||
`prompts` repo over HTTP and writes them into the repo; identical across
|
files from the `prompts` repo over HTTP and writes them into the repo;
|
||||||
repos
|
identical across repos
|
||||||
- [ ] `script/update-policy` / `make update-policy` — fetches the current
|
- [ ] `script/update-policy` / `make update-policy` — fetches the current
|
||||||
`script/fetch-policy`, runs it on the repo and commits the result without
|
`script/commit-current-upstream-policy-docs`, runs it on the repo and
|
||||||
pushing; identical across repos
|
commits the result without pushing; identical across repos
|
||||||
- [ ] README **Entrypoints** section documents the scripts and links the
|
- [ ] README **Entrypoints** section documents the scripts and links the
|
||||||
standard
|
standard
|
||||||
|
|
||||||
|
|||||||
+23
-20
@@ -110,7 +110,7 @@ style conventions are in separate documents:
|
|||||||
- `script/fmt-check`
|
- `script/fmt-check`
|
||||||
- `script/check`
|
- `script/check`
|
||||||
- `script/docker`
|
- `script/docker`
|
||||||
- `script/fetch-policy`
|
- `script/commit-current-upstream-policy-docs`
|
||||||
- `script/update-policy`
|
- `script/update-policy`
|
||||||
|
|
||||||
The scripts must be POSIX sh (`#!/bin/sh`, `set -eu`, no bashisms) so they
|
The scripts must be POSIX sh (`#!/bin/sh`, `set -eu`, no bashisms) so they
|
||||||
@@ -191,12 +191,13 @@ style conventions are in separate documents:
|
|||||||
`script/check`.
|
`script/check`.
|
||||||
- `script/install-precommit` installs the git pre-commit hook. The
|
- `script/install-precommit` installs the git pre-commit hook. The
|
||||||
`make hooks` target shims to it.
|
`make hooks` target shims to it.
|
||||||
- `script/fetch-policy` fetches the vendored policy files from the `prompts`
|
- `script/commit-current-upstream-policy-docs` fetches the vendored policy
|
||||||
repo over HTTP and writes them into the repo it is given, or its own repo
|
files from the `prompts` repo over HTTP and writes them into the repo it
|
||||||
with no argument.
|
is given, or its own repo with no argument.
|
||||||
- `script/update-policy` fetches the current `script/fetch-policy` from the
|
- `script/update-policy` fetches the current
|
||||||
`prompts` repo, runs it on its own repo and commits the result. It does
|
`script/commit-current-upstream-policy-docs` from the `prompts` repo, runs
|
||||||
not push. The `make update-policy` target shims to it.
|
it on its own repo and commits the result. It does not push. The
|
||||||
|
`make update-policy` target shims to it.
|
||||||
- `script/projectname` (literally that filename) simply outputs the
|
- `script/projectname` (literally that filename) simply outputs the
|
||||||
project's name.
|
project's name.
|
||||||
|
|
||||||
@@ -937,19 +938,20 @@ style conventions are in separate documents:
|
|||||||
feature branch.
|
feature branch.
|
||||||
|
|
||||||
- One command brings a repo up to standards: `make update-policy`. It runs
|
- One command brings a repo up to standards: `make update-policy`. It runs
|
||||||
`script/update-policy`, which fetches the current `script/fetch-policy` from
|
`script/update-policy`, which fetches the current
|
||||||
the head of `main` in the `prompts` repo and runs it on the repo. It then
|
`script/commit-current-upstream-policy-docs` from the head of `main` in the
|
||||||
commits the files that changed and does not push, so a person reviews and
|
`prompts` repo and runs it on the repo. It then commits the files that changed
|
||||||
pushes the commit.
|
and does not push, so a person reviews and pushes the commit.
|
||||||
|
|
||||||
`script/fetch-policy` fetches each vendored file from `prompts` over HTTP
|
`script/commit-current-upstream-policy-docs` fetches each vendored file from
|
||||||
and writes it into the repo. It skips a language's files when git tracks no
|
`prompts` over HTTP and writes it into the repo. It skips a language's files
|
||||||
source file of that language. A file the repo lacks is written whole. A
|
when git tracks no source file of that language. A file the repo lacks is
|
||||||
`prompts/NAME.md` goes to `docs/NAME.md`, unless the repo keeps it at
|
written whole. A `prompts/NAME.md` goes to `docs/NAME.md`, unless the repo
|
||||||
`NAME.md`. It also writes `script/fetch-policy` and `script/update-policy`
|
keeps it at `NAME.md`. It also writes
|
||||||
into the repo, so a repo updated once can update itself. The list of
|
`script/commit-current-upstream-policy-docs` and `script/update-policy` into
|
||||||
vendored files is at the top of `script/fetch-policy`. The script replaces
|
the repo, so a repo updated once can update itself. The list of vendored
|
||||||
each file and keeps only the repo's own entries:
|
files is at the top of `script/commit-current-upstream-policy-docs`. The
|
||||||
|
script replaces each file and keeps only the repo's own entries:
|
||||||
- in `.gitignore`, `.editorconfig` and `.dockerignore`: the lines below the
|
- in `.gitignore`, `.editorconfig` and `.dockerignore`: the lines below the
|
||||||
comment that ends the canonical file
|
comment that ends the canonical file
|
||||||
- in a `.gitignore` or `.dockerignore` lacking that comment: every entry the
|
- in a `.gitignore` or `.dockerignore` lacking that comment: every entry the
|
||||||
@@ -1182,7 +1184,8 @@ style conventions are in separate documents:
|
|||||||
- `Makefile`
|
- `Makefile`
|
||||||
- `script/` entrypoints (`bootstrap`, `setup`, `projectname`, `test`,
|
- `script/` entrypoints (`bootstrap`, `setup`, `projectname`, `test`,
|
||||||
`lint`, `fmt`, `fmt-check`, `check`, `docker`, `cibuild`, `precommit`,
|
`lint`, `fmt`, `fmt-check`, `check`, `docker`, `cibuild`, `precommit`,
|
||||||
`install-precommit`, `fetch-policy`, `update-policy`)
|
`install-precommit`, `commit-current-upstream-policy-docs`,
|
||||||
|
`update-policy`)
|
||||||
- `Dockerfile`, `.dockerignore`
|
- `Dockerfile`, `.dockerignore`
|
||||||
- `.gitea/workflows/check.yml`
|
- `.gitea/workflows/check.yml`
|
||||||
- Go: `go.mod`, `go.sum`, `.golangci.yml`
|
- Go: `go.mod`, `go.sum`, `.golangci.yml`
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# script/fetch-policy: write the current policy files from the prompts
|
# script/commit-current-upstream-policy-docs: write the current policy
|
||||||
# repo into a repo clone, over HTTP. It commits nothing;
|
# files from the prompts repo into a repo clone, over HTTP. It commits
|
||||||
# script/update-policy does that. Identical in all repos. Our own
|
# nothing; script/update-policy does that. Identical in all repos. Our
|
||||||
# extension to scripts-to-rule-them-all.
|
# own extension to scripts-to-rule-them-all.
|
||||||
#
|
#
|
||||||
# Usage: script/fetch-policy [path of a repo clone]
|
# Usage: script/commit-current-upstream-policy-docs [path of a repo clone]
|
||||||
# Without a path it updates the repo this script sits in.
|
# Without a path it updates the repo this script sits in.
|
||||||
#
|
#
|
||||||
# Standard output is the full hash of the prompts commit, then each path
|
# Standard output is the full hash of the prompts commit, then each path
|
||||||
@@ -50,12 +50,12 @@ prompts/GO_HTTP_SERVER_CONVENTIONS.md
|
|||||||
prompts/LLM_PROSE_TELLS.md
|
prompts/LLM_PROSE_TELLS.md
|
||||||
prompts/NEW_REPO_CHECKLIST.md
|
prompts/NEW_REPO_CHECKLIST.md
|
||||||
prompts/REPO_POLICIES.md
|
prompts/REPO_POLICIES.md
|
||||||
script/fetch-policy
|
script/commit-current-upstream-policy-docs
|
||||||
script/update-policy
|
script/update-policy
|
||||||
"
|
"
|
||||||
|
|
||||||
die() {
|
die() {
|
||||||
echo "fetch-policy: $*" >&2
|
echo "commit-current-upstream-policy-docs: $*" >&2
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,7 +226,8 @@ $own"
|
|||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
[ "$#" -le 1 ] || die "usage: script/fetch-policy [path of a repo clone]"
|
[ "$#" -le 1 ] ||
|
||||||
|
die "usage: script/commit-current-upstream-policy-docs [path of a repo clone]"
|
||||||
|
|
||||||
target="${1:-$(dirname "$0")/..}"
|
target="${1:-$(dirname "$0")/..}"
|
||||||
cd "$target" || die "no such directory: $target"
|
cd "$target" || die "no such directory: $target"
|
||||||
@@ -1,12 +1,13 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# script/update-policy: bring this repo up to standards. It fetches the
|
# script/update-policy: bring this repo up to standards. It fetches the
|
||||||
# current script/fetch-policy from the prompts repo over HTTP, runs it
|
# current script/commit-current-upstream-policy-docs from the prompts
|
||||||
# on this repo and commits the files it wrote. It does not push.
|
# repo over HTTP, runs it on this repo and commits the files it wrote.
|
||||||
# Identical in all repos. Our own extension to scripts-to-rule-them-all.
|
# It does not push. Identical in all repos. Our own extension to
|
||||||
|
# scripts-to-rule-them-all.
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
ROOT="$(cd "$(dirname "$0")/.." && pwd -P)"
|
ROOT="$(cd "$(dirname "$0")/.." && pwd -P)"
|
||||||
FETCH_POLICY_URL="https://git.eeqj.de/sneak/prompts/raw/branch/main/script/fetch-policy"
|
COMMIT_CURRENT_UPSTREAM_POLICY_DOCS_URL="https://git.eeqj.de/sneak/prompts/raw/branch/main/script/commit-current-upstream-policy-docs"
|
||||||
|
|
||||||
die() {
|
die() {
|
||||||
echo "update-policy: $*" >&2
|
echo "update-policy: $*" >&2
|
||||||
@@ -22,10 +23,11 @@ main() {
|
|||||||
trap 'rm -rf "$tmp"' EXIT
|
trap 'rm -rf "$tmp"' EXIT
|
||||||
|
|
||||||
curl --fail --silent --show-error --max-time 60 \
|
curl --fail --silent --show-error --max-time 60 \
|
||||||
--output "$tmp/fetch-policy" "$FETCH_POLICY_URL" ||
|
--output "$tmp/commit-current-upstream-policy-docs" \
|
||||||
die "cannot fetch $FETCH_POLICY_URL"
|
"$COMMIT_CURRENT_UPSTREAM_POLICY_DOCS_URL" ||
|
||||||
|
die "cannot fetch $COMMIT_CURRENT_UPSTREAM_POLICY_DOCS_URL"
|
||||||
|
|
||||||
sh "$tmp/fetch-policy" "$ROOT" > "$tmp/written"
|
sh "$tmp/commit-current-upstream-policy-docs" "$ROOT" > "$tmp/written"
|
||||||
commit="$(head -n 1 "$tmp/written")"
|
commit="$(head -n 1 "$tmp/written")"
|
||||||
paths="$(tail -n +2 "$tmp/written")"
|
paths="$(tail -n +2 "$tmp/written")"
|
||||||
|
|
||||||
|
|||||||
+66
-59
@@ -1,13 +1,13 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# test/update-policy.sh: test script/fetch-policy and
|
# test/update-policy.sh: test script/commit-current-upstream-policy-docs
|
||||||
# script/update-policy on throwaway repos. Each scenario gets one temp
|
# and script/update-policy on throwaway repos. Each scenario gets one
|
||||||
# directory holding a repo, its local bare origin, a local git
|
# temp directory holding a repo, its local bare origin, a local git
|
||||||
# repository of the canonical files in place of prompts, and a stub curl
|
# repository of the canonical files in place of prompts, and a stub curl
|
||||||
# that serves them, so nothing touches the network.
|
# that serves them, so nothing touches the network.
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "$0")/.." && pwd -P)/script"
|
SCRIPT_DIR="$(cd "$(dirname "$0")/.." && pwd -P)/script"
|
||||||
FETCH_POLICY="$SCRIPT_DIR/fetch-policy"
|
COMMIT_CURRENT_UPSTREAM_POLICY_DOCS="$SCRIPT_DIR/commit-current-upstream-policy-docs"
|
||||||
UPDATE_POLICY="$SCRIPT_DIR/update-policy"
|
UPDATE_POLICY="$SCRIPT_DIR/update-policy"
|
||||||
|
|
||||||
dir=""
|
dir=""
|
||||||
@@ -60,8 +60,8 @@ case "$url" in
|
|||||||
"$HASH" 0000000000000000000000000000000000000000 > "$output"
|
"$HASH" 0000000000000000000000000000000000000000 > "$output"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
"$site/raw/branch/main/script/fetch-policy")
|
"$site/raw/branch/main/script/commit-current-upstream-policy-docs")
|
||||||
serve_file script/fetch-policy
|
serve_file script/commit-current-upstream-policy-docs
|
||||||
;;
|
;;
|
||||||
"$site/compare/$first...$HASH.patch")
|
"$site/compare/$first...$HASH.patch")
|
||||||
git -C "$canonical" format-patch --stdout --root "$HASH" > "$output"
|
git -C "$canonical" format-patch --stdout --root "$HASH" > "$output"
|
||||||
@@ -79,7 +79,8 @@ EOF
|
|||||||
|
|
||||||
write_canonical_files() {
|
write_canonical_files() {
|
||||||
mkdir -p "$dir/canonical/prompts" "$dir/canonical/script"
|
mkdir -p "$dir/canonical/prompts" "$dir/canonical/script"
|
||||||
cp "$FETCH_POLICY" "$UPDATE_POLICY" "$dir/canonical/script/"
|
cp "$COMMIT_CURRENT_UPSTREAM_POLICY_DOCS" "$UPDATE_POLICY" \
|
||||||
|
"$dir/canonical/script/"
|
||||||
cat > "$dir/canonical/.gitignore" << 'EOF'
|
cat > "$dir/canonical/.gitignore" << 'EOF'
|
||||||
*.log
|
*.log
|
||||||
*.tmp
|
*.tmp
|
||||||
@@ -208,7 +209,8 @@ start_scenario() {
|
|||||||
git -C "$dir/repo" remote add origin "$dir/origin.git"
|
git -C "$dir/repo" remote add origin "$dir/origin.git"
|
||||||
|
|
||||||
mkdir "$dir/repo/script"
|
mkdir "$dir/repo/script"
|
||||||
cp "$FETCH_POLICY" "$UPDATE_POLICY" "$dir/repo/script/"
|
cp "$COMMIT_CURRENT_UPSTREAM_POLICY_DOCS" "$UPDATE_POLICY" \
|
||||||
|
"$dir/repo/script/"
|
||||||
printf '#!/bin/sh\necho example\n' > "$dir/repo/script/projectname"
|
printf '#!/bin/sh\necho example\n' > "$dir/repo/script/projectname"
|
||||||
chmod +x "$dir/repo/script/projectname"
|
chmod +x "$dir/repo/script/projectname"
|
||||||
mkdir -p "$dir/repo/cmd/app"
|
mkdir -p "$dir/repo/cmd/app"
|
||||||
@@ -261,12 +263,13 @@ run_update_policy() {
|
|||||||
script/update-policy "$@") > "$dir/output" 2>&1 || status=$?
|
script/update-policy "$@") > "$dir/output" 2>&1 || status=$?
|
||||||
}
|
}
|
||||||
|
|
||||||
# run_fetch_policy <arguments>: run the script in this source tree,
|
# run_commit_current_upstream_policy_docs <arguments>: run the script in
|
||||||
# from outside the repo it updates.
|
# this source tree, from outside the repo it updates.
|
||||||
run_fetch_policy() {
|
run_commit_current_upstream_policy_docs() {
|
||||||
status=0
|
status=0
|
||||||
(cd "$dir" && PATH="$dir/bin:$PATH" TMPDIR="$dir/tmp" \
|
(cd "$dir" && PATH="$dir/bin:$PATH" TMPDIR="$dir/tmp" \
|
||||||
"$FETCH_POLICY" "$@") > "$dir/output" 2>&1 || status=$?
|
"$COMMIT_CURRENT_UPSTREAM_POLICY_DOCS" "$@") > "$dir/output" 2>&1 ||
|
||||||
|
status=$?
|
||||||
}
|
}
|
||||||
|
|
||||||
head_of_repo() {
|
head_of_repo() {
|
||||||
@@ -478,27 +481,27 @@ test_nothing_changed() {
|
|||||||
expect_nothing_written
|
expect_nothing_written
|
||||||
}
|
}
|
||||||
|
|
||||||
test_target_lacking_fetch_policy_gets_both_scripts() {
|
test_target_lacking_commit_current_upstream_policy_docs_gets_both_scripts() {
|
||||||
start_scenario "a repo lacking script/fetch-policy gets it, and the current script/update-policy, in the commit"
|
start_scenario "a repo lacking script/commit-current-upstream-policy-docs gets it, and the current script/update-policy, in the commit"
|
||||||
rm "$dir/repo/script/fetch-policy"
|
rm "$dir/repo/script/commit-current-upstream-policy-docs"
|
||||||
echo "# An older version." >> "$dir/repo/script/update-policy"
|
echo "# An older version." >> "$dir/repo/script/update-policy"
|
||||||
commit_and_push_fixture .prettierrc
|
commit_and_push_fixture .prettierrc
|
||||||
run_update_policy
|
run_update_policy
|
||||||
expect_success
|
expect_success
|
||||||
expect_same_as_canonical script/fetch-policy
|
expect_same_as_canonical script/commit-current-upstream-policy-docs
|
||||||
expect_same_as_canonical script/update-policy
|
expect_same_as_canonical script/update-policy
|
||||||
expect_committed_executable script/fetch-policy
|
expect_committed_executable script/commit-current-upstream-policy-docs
|
||||||
expect_committed_executable script/update-policy
|
expect_committed_executable script/update-policy
|
||||||
expect_new_commit_not_pushed
|
expect_new_commit_not_pushed
|
||||||
[ "$(files_in_commit)" = ".prettierrc script/fetch-policy script/update-policy " ] ||
|
[ "$(files_in_commit)" = ".prettierrc script/commit-current-upstream-policy-docs script/update-policy " ] ||
|
||||||
fail "the commit holds other files: $(files_in_commit)"
|
fail "the commit holds other files: $(files_in_commit)"
|
||||||
}
|
}
|
||||||
|
|
||||||
# The shell reads a script in blocks, so the padding makes it read the
|
# The shell reads a script in blocks, so the padding makes it read the
|
||||||
# last line only after main has returned. It finds that line only if
|
# last line only after main has returned. It finds that line only if
|
||||||
# script/fetch-policy left the old file in place under a new name. The
|
# script/commit-current-upstream-policy-docs left the old file in place
|
||||||
# old file is an earlier canonical version, so script/fetch-policy
|
# under a new name. The old file is an earlier canonical version, so
|
||||||
# replaces it.
|
# script/commit-current-upstream-policy-docs replaces it.
|
||||||
test_update_policy_replaces_itself() {
|
test_update_policy_replaces_itself() {
|
||||||
start_scenario "script/update-policy replaces its own file and still exits 0"
|
start_scenario "script/update-policy replaces its own file and still exits 0"
|
||||||
{
|
{
|
||||||
@@ -525,44 +528,46 @@ test_update_policy_replaces_itself() {
|
|||||||
expect_new_commit_not_pushed
|
expect_new_commit_not_pushed
|
||||||
}
|
}
|
||||||
|
|
||||||
test_fetch_policy_with_path_commits_nothing() {
|
test_commit_current_upstream_policy_docs_with_path_commits_nothing() {
|
||||||
start_scenario "script/fetch-policy with a path writes into that clone and commits nothing"
|
start_scenario "script/commit-current-upstream-policy-docs with a path writes into that clone and commits nothing"
|
||||||
rm "$dir/repo/script/fetch-policy" "$dir/repo/script/update-policy"
|
rm "$dir/repo/script/commit-current-upstream-policy-docs" \
|
||||||
|
"$dir/repo/script/update-policy"
|
||||||
commit_and_push_fixture .prettierrc
|
commit_and_push_fixture .prettierrc
|
||||||
run_fetch_policy "$dir/repo"
|
run_commit_current_upstream_policy_docs "$dir/repo"
|
||||||
expect_success
|
expect_success
|
||||||
expect_file .prettierrc << 'EOF'
|
expect_file .prettierrc << 'EOF'
|
||||||
{ "tabWidth": 4 }
|
{ "tabWidth": 4 }
|
||||||
EOF
|
EOF
|
||||||
expect_same_as_canonical script/fetch-policy
|
expect_same_as_canonical script/commit-current-upstream-policy-docs
|
||||||
expect_same_as_canonical script/update-policy
|
expect_same_as_canonical script/update-policy
|
||||||
expect_executable script/fetch-policy
|
expect_executable script/commit-current-upstream-policy-docs
|
||||||
expect_executable script/update-policy
|
expect_executable script/update-policy
|
||||||
expect_no_commit
|
expect_no_commit
|
||||||
[ "$(head -n 1 "$dir/output")" = "$HASH" ] ||
|
[ "$(head -n 1 "$dir/output")" = "$HASH" ] ||
|
||||||
fail "the first line of output is not the hash"
|
fail "the first line of output is not the hash"
|
||||||
expect_output "script/fetch-policy"
|
expect_output "script/commit-current-upstream-policy-docs"
|
||||||
[ -z "$(ls -A "$dir/tmp")" ] || fail "a temporary directory is left"
|
[ -z "$(ls -A "$dir/tmp")" ] || fail "a temporary directory is left"
|
||||||
}
|
}
|
||||||
|
|
||||||
test_fetch_policy_without_script_directory() {
|
test_commit_current_upstream_policy_docs_without_script_directory() {
|
||||||
start_scenario "script/fetch-policy with a path writes both scripts into a clone with no script directory"
|
start_scenario "script/commit-current-upstream-policy-docs with a path writes both scripts into a clone with no script directory"
|
||||||
commit_and_push_fixture .prettierrc
|
commit_and_push_fixture .prettierrc
|
||||||
remove_from_fixture script
|
remove_from_fixture script
|
||||||
run_fetch_policy "$dir/repo"
|
run_commit_current_upstream_policy_docs "$dir/repo"
|
||||||
expect_success
|
expect_success
|
||||||
expect_same_as_canonical script/fetch-policy
|
expect_same_as_canonical script/commit-current-upstream-policy-docs
|
||||||
expect_same_as_canonical script/update-policy
|
expect_same_as_canonical script/update-policy
|
||||||
expect_executable script/fetch-policy
|
expect_executable script/commit-current-upstream-policy-docs
|
||||||
expect_executable script/update-policy
|
expect_executable script/update-policy
|
||||||
expect_no_commit
|
expect_no_commit
|
||||||
}
|
}
|
||||||
|
|
||||||
test_fetch_policy_without_argument_updates_own_repo() {
|
test_commit_current_upstream_policy_docs_without_argument_updates_own_repo() {
|
||||||
start_scenario "script/fetch-policy with no argument updates the repo it sits in"
|
start_scenario "script/commit-current-upstream-policy-docs with no argument updates the repo it sits in"
|
||||||
commit_and_push_fixture .prettierrc
|
commit_and_push_fixture .prettierrc
|
||||||
status=0
|
status=0
|
||||||
(cd "$dir" && PATH="$dir/bin:$PATH" repo/script/fetch-policy) \
|
(cd "$dir" && PATH="$dir/bin:$PATH" \
|
||||||
|
repo/script/commit-current-upstream-policy-docs) \
|
||||||
> "$dir/output" 2>&1 || status=$?
|
> "$dir/output" 2>&1 || status=$?
|
||||||
expect_success
|
expect_success
|
||||||
expect_file .prettierrc << 'EOF'
|
expect_file .prettierrc << 'EOF'
|
||||||
@@ -571,19 +576,19 @@ EOF
|
|||||||
expect_no_commit
|
expect_no_commit
|
||||||
}
|
}
|
||||||
|
|
||||||
test_fetch_policy_bad_target() {
|
test_commit_current_upstream_policy_docs_bad_target() {
|
||||||
start_scenario "script/fetch-policy refuses a path that is not the top of a clone"
|
start_scenario "script/commit-current-upstream-policy-docs refuses a path that is not the top of a clone"
|
||||||
commit_and_push_fixture .prettierrc
|
commit_and_push_fixture .prettierrc
|
||||||
run_fetch_policy "$dir/repo/script"
|
run_commit_current_upstream_policy_docs "$dir/repo/script"
|
||||||
expect_failure
|
expect_failure
|
||||||
expect_output "not the top of a git clone"
|
expect_output "not the top of a git clone"
|
||||||
run_fetch_policy "$dir/bin"
|
run_commit_current_upstream_policy_docs "$dir/bin"
|
||||||
expect_failure
|
expect_failure
|
||||||
expect_output "not the top of a git clone"
|
expect_output "not the top of a git clone"
|
||||||
run_fetch_policy "$dir/no-such-directory"
|
run_commit_current_upstream_policy_docs "$dir/no-such-directory"
|
||||||
expect_failure
|
expect_failure
|
||||||
expect_output "no such directory"
|
expect_output "no such directory"
|
||||||
run_fetch_policy "$dir/repo" extra
|
run_commit_current_upstream_policy_docs "$dir/repo" extra
|
||||||
expect_failure
|
expect_failure
|
||||||
expect_output "usage:"
|
expect_output "usage:"
|
||||||
expect_nothing_written
|
expect_nothing_written
|
||||||
@@ -592,7 +597,7 @@ test_fetch_policy_bad_target() {
|
|||||||
test_failed_fetch_stops() {
|
test_failed_fetch_stops() {
|
||||||
for url in \
|
for url in \
|
||||||
"/api/v1/repos/sneak/prompts/branches/main" \
|
"/api/v1/repos/sneak/prompts/branches/main" \
|
||||||
"/raw/branch/main/script/fetch-policy" \
|
"/raw/branch/main/script/commit-current-upstream-policy-docs" \
|
||||||
"/compare/" \
|
"/compare/" \
|
||||||
"/raw/commit/"; do
|
"/raw/commit/"; do
|
||||||
start_scenario "a failed fetch of $url stops with nothing written"
|
start_scenario "a failed fetch of $url stops with nothing written"
|
||||||
@@ -662,14 +667,14 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
test_untracked_script_stops() {
|
test_untracked_script_stops() {
|
||||||
start_scenario "an untracked script/fetch-policy is not overwritten"
|
start_scenario "an untracked script/commit-current-upstream-policy-docs is not overwritten"
|
||||||
rm "$dir/repo/script/fetch-policy"
|
rm "$dir/repo/script/commit-current-upstream-policy-docs"
|
||||||
commit_and_push_fixture .prettierrc
|
commit_and_push_fixture .prettierrc
|
||||||
echo "our own script" > "$dir/repo/script/fetch-policy"
|
echo "our own script" > "$dir/repo/script/commit-current-upstream-policy-docs"
|
||||||
run_fetch_policy "$dir/repo"
|
run_commit_current_upstream_policy_docs "$dir/repo"
|
||||||
expect_failure
|
expect_failure
|
||||||
expect_output "script/fetch-policy has uncommitted changes"
|
expect_output "script/commit-current-upstream-policy-docs has uncommitted changes"
|
||||||
expect_file script/fetch-policy << 'EOF'
|
expect_file script/commit-current-upstream-policy-docs << 'EOF'
|
||||||
our own script
|
our own script
|
||||||
EOF
|
EOF
|
||||||
expect_no_commit
|
expect_no_commit
|
||||||
@@ -681,7 +686,7 @@ test_ignored_file_stops() {
|
|||||||
remove_from_fixture docs/API_POLICIES.md
|
remove_from_fixture docs/API_POLICIES.md
|
||||||
echo "docs/API_POLICIES.md" >> "$dir/repo/.git/info/exclude"
|
echo "docs/API_POLICIES.md" >> "$dir/repo/.git/info/exclude"
|
||||||
echo "our own notes" > "$dir/repo/docs/API_POLICIES.md"
|
echo "our own notes" > "$dir/repo/docs/API_POLICIES.md"
|
||||||
run_fetch_policy "$dir/repo"
|
run_commit_current_upstream_policy_docs "$dir/repo"
|
||||||
expect_failure
|
expect_failure
|
||||||
expect_output "docs/API_POLICIES.md is ignored by git"
|
expect_output "docs/API_POLICIES.md is ignored by git"
|
||||||
expect_file docs/API_POLICIES.md << 'EOF'
|
expect_file docs/API_POLICIES.md << 'EOF'
|
||||||
@@ -691,7 +696,8 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
test_own_script_stops() {
|
test_own_script_stops() {
|
||||||
for script in script/fetch-policy script/update-policy; do
|
for script in script/commit-current-upstream-policy-docs \
|
||||||
|
script/update-policy; do
|
||||||
start_scenario "a tracked $script with a line the canonical file has never held stops"
|
start_scenario "a tracked $script with a line the canonical file has never held stops"
|
||||||
echo "echo our own script" >> "$dir/repo/$script"
|
echo "echo our own script" >> "$dir/repo/$script"
|
||||||
commit_and_push_fixture .prettierrc
|
commit_and_push_fixture .prettierrc
|
||||||
@@ -849,9 +855,10 @@ test_former_canonical_gitignore_line_replaced() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test_former_canonical_script_line_replaced() {
|
test_former_canonical_script_line_replaced() {
|
||||||
start_scenario "a script/fetch-policy line an earlier canonical commit held is replaced"
|
start_scenario "a script/commit-current-upstream-policy-docs line an earlier canonical commit held is replaced"
|
||||||
expect_former_canonical_line_replaced script/fetch-policy "echo an older version"
|
expect_former_canonical_line_replaced \
|
||||||
expect_same_as_canonical script/fetch-policy
|
script/commit-current-upstream-policy-docs "echo an older version"
|
||||||
|
expect_same_as_canonical script/commit-current-upstream-policy-docs
|
||||||
}
|
}
|
||||||
|
|
||||||
# A line another file's history removed does not count as held by this
|
# A line another file's history removed does not count as held by this
|
||||||
@@ -879,12 +886,12 @@ main() {
|
|||||||
test_language_files_need_a_source_file
|
test_language_files_need_a_source_file
|
||||||
test_javascript_source_brings_its_styleguide
|
test_javascript_source_brings_its_styleguide
|
||||||
test_nothing_changed
|
test_nothing_changed
|
||||||
test_target_lacking_fetch_policy_gets_both_scripts
|
test_target_lacking_commit_current_upstream_policy_docs_gets_both_scripts
|
||||||
test_update_policy_replaces_itself
|
test_update_policy_replaces_itself
|
||||||
test_fetch_policy_with_path_commits_nothing
|
test_commit_current_upstream_policy_docs_with_path_commits_nothing
|
||||||
test_fetch_policy_without_script_directory
|
test_commit_current_upstream_policy_docs_without_script_directory
|
||||||
test_fetch_policy_without_argument_updates_own_repo
|
test_commit_current_upstream_policy_docs_without_argument_updates_own_repo
|
||||||
test_fetch_policy_bad_target
|
test_commit_current_upstream_policy_docs_bad_target
|
||||||
test_failed_fetch_stops
|
test_failed_fetch_stops
|
||||||
test_one_missing_file_stops_all
|
test_one_missing_file_stops_all
|
||||||
test_branch_response_without_hash_stops
|
test_branch_response_without_hash_stops
|
||||||
|
|||||||
Reference in new issue
Block a user