expand: repo auto-detect, --web, editor, PR diff/checks/ready/review/status, repo lifecycle, api headers/paginate
* CI: pre-push hook (fmt, clippy -D warnings, test, release build) plus
opt-in FJ_E2E=1 smoke. Install via scripts/install-hooks.sh.
* Repo auto-detection from git remote: -R/--repo becomes optional on all
repo-scoped subcommands. Detection prefers `upstream` then `origin`,
honors --host, and parses https/ssh/scp-style URLs.
* `--web` flag wired to every list/view command (open in default browser).
* `$EDITOR` integration for issue/pr create + comment + edit (omit
`--body` to launch your editor; `-` keeps stdin).
* PR: new `diff`, `commits`, `files`, `checks`, `ready`, `review`,
`edit`, `status`, `reopen` subcommands. `view --comments` now shows
reviews too.
* Issue: `edit` and `develop` (creates a branch for the issue).
* Repo: `fork`, `sync`, `edit`, `rename`, `archive`, `unarchive`,
`delete` (with slug-confirmation), `branches`, `topics`.
* `fj api` gains `-H` headers, `--paginate` (follows Link rel=next),
`--include` (response headers), `--silent`. The jq-ish projector now
supports `[N]`/`[-N]` brackets and `|` pipes.
* MSRV bumped to 1.82 (uses `is_none_or`).
* 46 unit tests covering pure logic: hosts CRUD, remote URL parsing,
link header parser, jq projection, branch label fallback, slugify.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-13 15:22:40 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
# fj pre-push hook — local CI gate.
|
|
|
|
|
# Runs fmt-check, clippy, tests, and a release build. With FJ_E2E=1 also
|
|
|
|
|
# runs the live-API smoke suite against the currently signed-in host.
|
2026-05-13 15:53:13 +00:00
|
|
|
#
|
|
|
|
|
# This script is invoked by git push with the list of refs being pushed on
|
|
|
|
|
# stdin. We close stdin ourselves and run every step with stdin redirected
|
|
|
|
|
# from /dev/null so cargo / tests can't accidentally block waiting for input.
|
expand: repo auto-detect, --web, editor, PR diff/checks/ready/review/status, repo lifecycle, api headers/paginate
* CI: pre-push hook (fmt, clippy -D warnings, test, release build) plus
opt-in FJ_E2E=1 smoke. Install via scripts/install-hooks.sh.
* Repo auto-detection from git remote: -R/--repo becomes optional on all
repo-scoped subcommands. Detection prefers `upstream` then `origin`,
honors --host, and parses https/ssh/scp-style URLs.
* `--web` flag wired to every list/view command (open in default browser).
* `$EDITOR` integration for issue/pr create + comment + edit (omit
`--body` to launch your editor; `-` keeps stdin).
* PR: new `diff`, `commits`, `files`, `checks`, `ready`, `review`,
`edit`, `status`, `reopen` subcommands. `view --comments` now shows
reviews too.
* Issue: `edit` and `develop` (creates a branch for the issue).
* Repo: `fork`, `sync`, `edit`, `rename`, `archive`, `unarchive`,
`delete` (with slug-confirmation), `branches`, `topics`.
* `fj api` gains `-H` headers, `--paginate` (follows Link rel=next),
`--include` (response headers), `--silent`. The jq-ish projector now
supports `[N]`/`[-N]` brackets and `|` pipes.
* MSRV bumped to 1.82 (uses `is_none_or`).
* 46 unit tests covering pure logic: hosts CRUD, remote URL parsing,
link header parser, jq projection, branch label fallback, slugify.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-13 15:22:40 +00:00
|
|
|
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
|
|
cd "$(git rev-parse --show-toplevel)"
|
|
|
|
|
|
|
|
|
|
# Allow skip in genuine emergencies. Don't use this unless you know why.
|
|
|
|
|
if [[ "${FJ_SKIP_PREPUSH:-0}" = "1" ]]; then
|
|
|
|
|
echo "fj pre-push: skipped (FJ_SKIP_PREPUSH=1)"
|
|
|
|
|
exit 0
|
|
|
|
|
fi
|
|
|
|
|
|
2026-05-13 15:53:13 +00:00
|
|
|
# Drain whatever git fed us on stdin so we don't deadlock if a child inherits
|
|
|
|
|
# our stdin and blocks. Then close it for the rest of the hook.
|
|
|
|
|
cat >/dev/null || true
|
|
|
|
|
exec 0</dev/null
|
|
|
|
|
|
|
|
|
|
# Compact output even when stderr is a TTY (the hook usually isn't run
|
|
|
|
|
# interactively).
|
|
|
|
|
export CARGO_TERM_COLOR=auto
|
|
|
|
|
export CARGO_TERM_PROGRESS_WHEN=never
|
|
|
|
|
|
expand: repo auto-detect, --web, editor, PR diff/checks/ready/review/status, repo lifecycle, api headers/paginate
* CI: pre-push hook (fmt, clippy -D warnings, test, release build) plus
opt-in FJ_E2E=1 smoke. Install via scripts/install-hooks.sh.
* Repo auto-detection from git remote: -R/--repo becomes optional on all
repo-scoped subcommands. Detection prefers `upstream` then `origin`,
honors --host, and parses https/ssh/scp-style URLs.
* `--web` flag wired to every list/view command (open in default browser).
* `$EDITOR` integration for issue/pr create + comment + edit (omit
`--body` to launch your editor; `-` keeps stdin).
* PR: new `diff`, `commits`, `files`, `checks`, `ready`, `review`,
`edit`, `status`, `reopen` subcommands. `view --comments` now shows
reviews too.
* Issue: `edit` and `develop` (creates a branch for the issue).
* Repo: `fork`, `sync`, `edit`, `rename`, `archive`, `unarchive`,
`delete` (with slug-confirmation), `branches`, `topics`.
* `fj api` gains `-H` headers, `--paginate` (follows Link rel=next),
`--include` (response headers), `--silent`. The jq-ish projector now
supports `[N]`/`[-N]` brackets and `|` pipes.
* MSRV bumped to 1.82 (uses `is_none_or`).
* 46 unit tests covering pure logic: hosts CRUD, remote URL parsing,
link header parser, jq projection, branch label fallback, slugify.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-13 15:22:40 +00:00
|
|
|
step() {
|
2026-05-13 15:53:13 +00:00
|
|
|
printf '\n\033[1;34m== %s ==\033[0m\n' "$*" >&2
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
run() {
|
|
|
|
|
# Run with stdin closed and stdout/stderr passed through.
|
|
|
|
|
"$@" </dev/null
|
expand: repo auto-detect, --web, editor, PR diff/checks/ready/review/status, repo lifecycle, api headers/paginate
* CI: pre-push hook (fmt, clippy -D warnings, test, release build) plus
opt-in FJ_E2E=1 smoke. Install via scripts/install-hooks.sh.
* Repo auto-detection from git remote: -R/--repo becomes optional on all
repo-scoped subcommands. Detection prefers `upstream` then `origin`,
honors --host, and parses https/ssh/scp-style URLs.
* `--web` flag wired to every list/view command (open in default browser).
* `$EDITOR` integration for issue/pr create + comment + edit (omit
`--body` to launch your editor; `-` keeps stdin).
* PR: new `diff`, `commits`, `files`, `checks`, `ready`, `review`,
`edit`, `status`, `reopen` subcommands. `view --comments` now shows
reviews too.
* Issue: `edit` and `develop` (creates a branch for the issue).
* Repo: `fork`, `sync`, `edit`, `rename`, `archive`, `unarchive`,
`delete` (with slug-confirmation), `branches`, `topics`.
* `fj api` gains `-H` headers, `--paginate` (follows Link rel=next),
`--include` (response headers), `--silent`. The jq-ish projector now
supports `[N]`/`[-N]` brackets and `|` pipes.
* MSRV bumped to 1.82 (uses `is_none_or`).
* 46 unit tests covering pure logic: hosts CRUD, remote URL parsing,
link header parser, jq projection, branch label fallback, slugify.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-13 15:22:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
step "cargo fmt --check"
|
2026-05-13 15:53:13 +00:00
|
|
|
run cargo fmt --all -- --check
|
expand: repo auto-detect, --web, editor, PR diff/checks/ready/review/status, repo lifecycle, api headers/paginate
* CI: pre-push hook (fmt, clippy -D warnings, test, release build) plus
opt-in FJ_E2E=1 smoke. Install via scripts/install-hooks.sh.
* Repo auto-detection from git remote: -R/--repo becomes optional on all
repo-scoped subcommands. Detection prefers `upstream` then `origin`,
honors --host, and parses https/ssh/scp-style URLs.
* `--web` flag wired to every list/view command (open in default browser).
* `$EDITOR` integration for issue/pr create + comment + edit (omit
`--body` to launch your editor; `-` keeps stdin).
* PR: new `diff`, `commits`, `files`, `checks`, `ready`, `review`,
`edit`, `status`, `reopen` subcommands. `view --comments` now shows
reviews too.
* Issue: `edit` and `develop` (creates a branch for the issue).
* Repo: `fork`, `sync`, `edit`, `rename`, `archive`, `unarchive`,
`delete` (with slug-confirmation), `branches`, `topics`.
* `fj api` gains `-H` headers, `--paginate` (follows Link rel=next),
`--include` (response headers), `--silent`. The jq-ish projector now
supports `[N]`/`[-N]` brackets and `|` pipes.
* MSRV bumped to 1.82 (uses `is_none_or`).
* 46 unit tests covering pure logic: hosts CRUD, remote URL parsing,
link header parser, jq projection, branch label fallback, slugify.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-13 15:22:40 +00:00
|
|
|
|
|
|
|
|
step "cargo clippy (deny warnings)"
|
2026-05-13 15:53:13 +00:00
|
|
|
run cargo clippy --all-targets --all-features -- -D warnings
|
expand: repo auto-detect, --web, editor, PR diff/checks/ready/review/status, repo lifecycle, api headers/paginate
* CI: pre-push hook (fmt, clippy -D warnings, test, release build) plus
opt-in FJ_E2E=1 smoke. Install via scripts/install-hooks.sh.
* Repo auto-detection from git remote: -R/--repo becomes optional on all
repo-scoped subcommands. Detection prefers `upstream` then `origin`,
honors --host, and parses https/ssh/scp-style URLs.
* `--web` flag wired to every list/view command (open in default browser).
* `$EDITOR` integration for issue/pr create + comment + edit (omit
`--body` to launch your editor; `-` keeps stdin).
* PR: new `diff`, `commits`, `files`, `checks`, `ready`, `review`,
`edit`, `status`, `reopen` subcommands. `view --comments` now shows
reviews too.
* Issue: `edit` and `develop` (creates a branch for the issue).
* Repo: `fork`, `sync`, `edit`, `rename`, `archive`, `unarchive`,
`delete` (with slug-confirmation), `branches`, `topics`.
* `fj api` gains `-H` headers, `--paginate` (follows Link rel=next),
`--include` (response headers), `--silent`. The jq-ish projector now
supports `[N]`/`[-N]` brackets and `|` pipes.
* MSRV bumped to 1.82 (uses `is_none_or`).
* 46 unit tests covering pure logic: hosts CRUD, remote URL parsing,
link header parser, jq projection, branch label fallback, slugify.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-13 15:22:40 +00:00
|
|
|
|
|
|
|
|
step "cargo test"
|
2026-05-13 15:53:13 +00:00
|
|
|
run cargo test --all --locked --no-fail-fast
|
expand: repo auto-detect, --web, editor, PR diff/checks/ready/review/status, repo lifecycle, api headers/paginate
* CI: pre-push hook (fmt, clippy -D warnings, test, release build) plus
opt-in FJ_E2E=1 smoke. Install via scripts/install-hooks.sh.
* Repo auto-detection from git remote: -R/--repo becomes optional on all
repo-scoped subcommands. Detection prefers `upstream` then `origin`,
honors --host, and parses https/ssh/scp-style URLs.
* `--web` flag wired to every list/view command (open in default browser).
* `$EDITOR` integration for issue/pr create + comment + edit (omit
`--body` to launch your editor; `-` keeps stdin).
* PR: new `diff`, `commits`, `files`, `checks`, `ready`, `review`,
`edit`, `status`, `reopen` subcommands. `view --comments` now shows
reviews too.
* Issue: `edit` and `develop` (creates a branch for the issue).
* Repo: `fork`, `sync`, `edit`, `rename`, `archive`, `unarchive`,
`delete` (with slug-confirmation), `branches`, `topics`.
* `fj api` gains `-H` headers, `--paginate` (follows Link rel=next),
`--include` (response headers), `--silent`. The jq-ish projector now
supports `[N]`/`[-N]` brackets and `|` pipes.
* MSRV bumped to 1.82 (uses `is_none_or`).
* 46 unit tests covering pure logic: hosts CRUD, remote URL parsing,
link header parser, jq projection, branch label fallback, slugify.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-13 15:22:40 +00:00
|
|
|
|
|
|
|
|
step "cargo build --release"
|
2026-05-13 15:53:13 +00:00
|
|
|
run cargo build --release --locked
|
expand: repo auto-detect, --web, editor, PR diff/checks/ready/review/status, repo lifecycle, api headers/paginate
* CI: pre-push hook (fmt, clippy -D warnings, test, release build) plus
opt-in FJ_E2E=1 smoke. Install via scripts/install-hooks.sh.
* Repo auto-detection from git remote: -R/--repo becomes optional on all
repo-scoped subcommands. Detection prefers `upstream` then `origin`,
honors --host, and parses https/ssh/scp-style URLs.
* `--web` flag wired to every list/view command (open in default browser).
* `$EDITOR` integration for issue/pr create + comment + edit (omit
`--body` to launch your editor; `-` keeps stdin).
* PR: new `diff`, `commits`, `files`, `checks`, `ready`, `review`,
`edit`, `status`, `reopen` subcommands. `view --comments` now shows
reviews too.
* Issue: `edit` and `develop` (creates a branch for the issue).
* Repo: `fork`, `sync`, `edit`, `rename`, `archive`, `unarchive`,
`delete` (with slug-confirmation), `branches`, `topics`.
* `fj api` gains `-H` headers, `--paginate` (follows Link rel=next),
`--include` (response headers), `--silent`. The jq-ish projector now
supports `[N]`/`[-N]` brackets and `|` pipes.
* MSRV bumped to 1.82 (uses `is_none_or`).
* 46 unit tests covering pure logic: hosts CRUD, remote URL parsing,
link header parser, jq projection, branch label fallback, slugify.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-13 15:22:40 +00:00
|
|
|
|
|
|
|
|
if [[ "${FJ_E2E:-0}" = "1" ]]; then
|
|
|
|
|
step "E2E smoke (live API)"
|
2026-05-13 15:53:13 +00:00
|
|
|
run ./scripts/e2e-smoke.sh
|
expand: repo auto-detect, --web, editor, PR diff/checks/ready/review/status, repo lifecycle, api headers/paginate
* CI: pre-push hook (fmt, clippy -D warnings, test, release build) plus
opt-in FJ_E2E=1 smoke. Install via scripts/install-hooks.sh.
* Repo auto-detection from git remote: -R/--repo becomes optional on all
repo-scoped subcommands. Detection prefers `upstream` then `origin`,
honors --host, and parses https/ssh/scp-style URLs.
* `--web` flag wired to every list/view command (open in default browser).
* `$EDITOR` integration for issue/pr create + comment + edit (omit
`--body` to launch your editor; `-` keeps stdin).
* PR: new `diff`, `commits`, `files`, `checks`, `ready`, `review`,
`edit`, `status`, `reopen` subcommands. `view --comments` now shows
reviews too.
* Issue: `edit` and `develop` (creates a branch for the issue).
* Repo: `fork`, `sync`, `edit`, `rename`, `archive`, `unarchive`,
`delete` (with slug-confirmation), `branches`, `topics`.
* `fj api` gains `-H` headers, `--paginate` (follows Link rel=next),
`--include` (response headers), `--silent`. The jq-ish projector now
supports `[N]`/`[-N]` brackets and `|` pipes.
* MSRV bumped to 1.82 (uses `is_none_or`).
* 46 unit tests covering pure logic: hosts CRUD, remote URL parsing,
link header parser, jq projection, branch label fallback, slugify.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-13 15:22:40 +00:00
|
|
|
fi
|
|
|
|
|
|
2026-05-13 15:53:13 +00:00
|
|
|
printf '\n\033[1;32m✓ pre-push checks passed\033[0m\n' >&2
|