Thanks for looking. A bug report with a reproduction — the directory layout
and the exact g invocation — is the most useful thing you can send; a
correction to somewhere the documentation misled you is a close second.
How this project writes prose — README, CHANGES, commit messages,
docstrings, source comments, and CLI/error text — is set out separately in
WRITING.md. Read that before changing any of it. The
constraints every change is held to, and the map of what is where, are in
AGENTS.md.
Install uv, then sync the dev and docs extras:
$ uv sync --all-extras --devCI is the order of record; every gate it runs has to pass before a change is done.
Format:
$ uv run ruff format .Lint:
$ uv run ruff check . --fix --show-fixesType-check the package, tests, and project configuration:
$ uv run ty check .Test:
$ uv run py.testDocumentation is a gate, not a courtesy. Examples in docstrings under
src/g and pages under docs/ are executed by pytest/py.test — the
doctest flags live in pyproject.toml, so there is no separate doctest
step and a green test run is the proof. README.md is not included, so its
examples are never executed. Which blocks qualify, and the one mistake that
silently removes a test, are in
WRITING.md.
Ruff's isort config requires from __future__ import annotations in every
module (required-imports, backed by the FA100 rule) — the linter, not
this file, catches a missing one. Import stdlib modules by namespace
(import typing as t, import logging) rather than from typing import …; third-party packages may use from X import Y. Nothing enforces this
one — it is a convention, not a lint rule.
Before claiming a test or a gate works, show it failing. A gate that has
never been red is an assumption. For bug fixes and behavioral changes,
verify new or updated pytest regressions fail inside the real owner
call when modified production files are restored to <base> and newly
added production files are removed temporarily:
$ : "${BITE_TEST:?set BITE_TEST to the regression test}" && \
wt=$(mktemp -d) && \
git worktree add --quiet --detach "$wt" HEAD && \
( cd "$wt" && \
base=${BITE_BASE:-origin/master} && \
git diff --name-only --no-renames "$base" HEAD | \
grep -E '\.py$' | \
grep -Ev '(^|/)tests?/|(^|/)conftest\.py$|(^|/)test_[^/]*\.py$|_test\.py$' \
> bite.files && \
git restore --source="$base" --worktree \
--pathspec-from-file=bite.files && \
{ uv run pytest -rf "$BITE_TEST" 2>&1 | tee bite.log; \
grep -E '^FAILED ' bite.log | \
grep -F -- "$BITE_TEST" | \
grep -Ev 'ImportError|ModuleNotFoundError'; } ); \
bite=$?; \
git worktree remove --force "$wt"; \
test "$bite" -eq 0This runs in a disposable git worktree at HEAD, so the checkout and any
uncommitted edit stay untouched; commit the change first. Set BITE_TEST to a
pytest node id such as tests/test_x.py::test_name. BITE_BASE defaults to
origin/master; set it to the pre-fix commit when the defect was introduced
earlier in the same pull request. The command succeeds only when the runner
reports that test as failed, and it prints the failure line. A missing runner,
a build error or an import error prints no such line, so it is not a bite.
Check that the printed failure is the assertion that describes the defect.
Tests live in tests/test_cli.py, parametrized through a
CommandLineTestFixture NamedTuple. The autouse setup fixture in
conftest.py sets G_IS_TEST=1 for every test, which makes run() return
the subprocess.Popen object instead of None so assertions can inspect
it — outside tests, run() always returns None.
CLI tests invoke real VCS binaries (at minimum git) rather than mocking
the subprocess call; use tmp_path and monkeypatch to simulate a
non-repo directory.
When subprocess output seems swallowed, set G_IS_TEST=1 and call
run(wait=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) to capture
it for inspection.
Assert on caplog.records attributes, not string matching on caplog.text
— caplog.record_tuples cannot see extra fields. Scope capture with
caplog.at_level(logging.DEBUG, logger="g") — g's modules log through
logging.getLogger(__name__), so the logger name is the module's own
dotted path, g at the package root. Filter records rather than index by
position: [r for r in caplog.records if hasattr(r, "vcs_cmd")].
Build once:
$ make build_docsLive-reloading preview at http://localhost:8034:
$ make start_docsFrom inside docs/, the same tasks are just html and just start; just --list in docs/ shows the rest (watch, serve, linkcheck,
doctest). make build_docs and just html both wrap
sphinx-build; nothing under docs/_build is hand-edited.
AGENTS.md and CLAUDE.md are excluded from the build
(exclude_patterns in docs/conf.py) — they are agent guidance, not site
pages. make build_docs catches a broken cross-reference; the test suite
does not, so build the docs before committing a documentation change.
Never create tags. Never push tags. The owner handles tagging and tag pushes, because a tag triggers the publish workflow. See Release commits.
- Update
CHANGESwith the release notes. - Bump the version in
src/g/__about__.pyandpyproject.toml. - Commit the release files with the subject
Tag v<version>. - Tag (
git tag v<version>) and push the branch, then the tag (git push --tags). - CI builds and publishes to PyPI automatically over OIDC trusted publishing once the tag lands.
Full detail: docs/project/releasing.md.
Use REVIEW.md for design and pull request review.
One subject per pull request. Unrelated cleanup found along the way belongs in its own commit, and usually in its own pull request.
Discuss a substantial change via an issue before making it.
Commit format is in WRITING.md.
Merge once you have the sign-off of one other developer. If you do not have permission to merge, ask a maintainer to merge it for you.
- Participants will be tolerant of opposing views.
- Participants must ensure that their language and actions are free of personal attacks and disparaging personal remarks.
- When interpreting the words and actions of others, participants should always assume good intentions.
- Behaviour which can be reasonably considered harassment will not be tolerated.
Based on Ruby's Community Conduct Guideline.
This repository has no SECURITY.md. Please do not open a public issue for
a vulnerability — report it privately via GitHub's security
advisories.