Metadata-Version: 2.4
Name: gitgatekeeper
Version: 0.1.1
Summary: Local-first Git automation agent: watches repos and writes safe, specific commits
Author: robertofilho0
License-Expression: MIT
Project-URL: Homepage, https://github.com/robertofilho0/GitGatekeeper
Project-URL: Issues, https://github.com/robertofilho0/GitGatekeeper/issues
Project-URL: Changelog, https://github.com/robertofilho0/GitGatekeeper/releases
Keywords: git,automation,commit,conventional-commits,local-first
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Version Control :: Git
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: watchdog>=7.1
Requires-Dist: pydantic>=2.11
Requires-Dist: pyyaml>=6.0
Requires-Dist: typer>=0.15
Requires-Dist: rich>=14.0
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == "dev"
Requires-Dist: pytest-cov>=6.0; extra == "dev"
Requires-Dist: ruff>=0.11; extra == "dev"
Provides-Extra: release
Requires-Dist: build>=1.2; extra == "release"
Requires-Dist: twine>=6.1; extra == "release"
Dynamic: license-file

# GitGatekeeper

GitGatekeeper is a local Git automation agent. It watches your repositories, waits
until you stop working on one, and then commits the changes with a
[Conventional Commit](https://www.conventionalcommits.org/) message. Pushing is
optional and **off by default**.

It is built to be boring and safe: it never rewrites history, never forces
anything, never touches what you staged yourself, and when it is not sure what
belongs in a commit, it does nothing and writes down why.

> Status: alpha (`0.1.0`). Linux only (developed and tested on Ubuntu 24.04).

**Local-first and open source.** GitGatekeeper makes no network requests of its own,
has no telemetry, and uses no external API or hosted AI model. Your code and
diffs never leave your machine. The only traffic is the `git push` you opt into
and the read-only `git ls-remote` that `gitgatekeeper check` runs against your own
remotes (skip it with `--offline`), both done by Git itself. Commit messages are written by transparent, deterministic
rules you can read in [`src/gitgatekeeper/intelligence/`](https://github.com/robertofilho0/GitGatekeeper/tree/main/src/gitgatekeeper/intelligence).
Tests enforce this (see [Tests](#tests)).

## Contents

- [How it works](#how-it-works)
- [Architecture](#architecture)
- [Installation](#installation)
- [Configuration](#configuration)
- [Command line](#command-line)
- [Running on Ubuntu](#running-on-ubuntu)
- [Running as a systemd user service](#running-as-a-systemd-user-service)
- [Security model](#security-model)
- [Commit messages](#commit-messages)
- [Data and logs](#data-and-logs)
- [Tests](#tests)
- [Known limitations](#known-limitations)
- [Roadmap](#roadmap)
- [Releasing](#releasing)
- [Contributing](#contributing)
- [License](#license)

## How it works

```
file change -> monitor -> inactivity detector --(quiet for N minutes)--> cycle

cycle:  commit engine -> [push engine, only if auto_push] -> history (SQLite)
```

1. A file watcher (Watchdog) reports changes per project, ignoring `.git/` and
   anything Git ignores.
2. Each project has its own inactivity timer (default 10 minutes). Every new
   change restarts it.
3. When a project has been quiet long enough, GitGatekeeper inspects it with the Git
   CLI, selects the files it may commit, builds a message with deterministic
   rules, and commits only those files.
4. If `auto_push` is enabled for that project, it pushes the current branch to
   its configured upstream.
5. Every outcome is recorded in a local SQLite database.

On start, GitGatekeeper also scans each project: work left over from before a restart
(uncommitted changes, or with `auto_push` unpublished commits) is queued again.

## Architecture

```
src/gitgatekeeper/
  config/         Pydantic models and YAML loading/saving
  core/
    project_manager.py  add / remove / enable / disable projects
    monitor.py          Watchdog-based repository monitor (debounced)
    inactivity.py       per-project inactivity timers
    detector.py         runs a callback when a project becomes eligible
    commit_engine.py    safe selection, secret scan, commit, rollback
    push_engine.py      safe push of the current branch
    locking.py          per-repository file locks
    instance.py         single running instance, safe stop
    service.py          the orchestrator behind `gitgatekeeper start`
  git/            Git CLI wrapper, status parser, analyzer, diff reader,
                  sensitive-file and secret detection
  intelligence/   commit messages: rules, project profile, code context
    profile.py          detects how a project is organised (modules)
    context.py          which functions/classes a change touched
    rules.py            the message generator
  storage/        SQLite database, history store, recorder
  cli/            Typer commands
  logging_setup.py  JSON-lines logging with credential masking
```

Design choices worth knowing:

- **Git CLI, not a Git library.** Behaviour matches what you get in a terminal,
  including your hooks and configuration. Every call has a timeout, never uses
  a shell, and a timed-out process group is killed as a whole.
- **Deterministic, local messages.** Messages come from rules, so the same change
  always yields the same message, and nothing is sent anywhere.
  `intelligence/provider.py` validates any generator's output and falls back to
  the built-in rules, so a custom generator can be plugged in without risk.
- **History is best effort and fails safe.** If the database cannot be written,
  GitGatekeeper never assumes a commit is its own and never skips a duplicate check
  in a way that could publish something it should not.

## Installation

Requirements: Linux, Python 3.12+, Git.

To use it, install it from PyPI (`pipx` keeps it in its own environment):

```bash
pipx install gitgatekeeper
gitgatekeeper --help
```

To work on it, clone the repository:

```bash
git clone git@github.com:robertofilho0/GitGatekeeper.git
cd GitGatekeeper
python3 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
gitgatekeeper --help
```

## Configuration

GitGatekeeper reads one YAML file. It is found in this order:

1. `--config <path>` on the command line
2. `$GITGATEKEEPER_CONFIG`
3. `./config/projects.yaml`
4. `~/.config/gitgatekeeper/projects.yaml`

A `./config/projects.yaml` that has no enabled project (such as the template in
a fresh checkout) is skipped while `~/.config/gitgatekeeper/projects.yaml` exists, so
running `gitgatekeeper` from inside a checkout does not hide your real config. A
local file that cannot be parsed is still used, so its error is shown.
`gitgatekeeper start` prints the file in use on its `Config:` line.

See [`config/projects.example.yaml`](https://github.com/robertofilho0/GitGatekeeper/blob/main/config/projects.example.yaml):

```yaml
inactivity_minutes: 10   # global default
auto_push: false         # global default
projects:
  - name: my-project
    path: /home/you/projects/my-project
    enabled: true
  - name: notes
    path: /home/you/notes
    inactivity_minutes: 30   # per-project override
    auto_push: true
```

### Protected branches and split commits

```yaml
protected_branches: [main, master]   # default; names or globs ("release/*")
split_commits: true                  # default
max_files_per_commit: 50             # default; a cycle with more files commits nothing
projects:
  - name: my-project
    path: /home/you/projects/my-project
    protected_branches: [main, "release/*"]   # per-project override
    split_commits: false
    max_files_per_commit: 150          # per-project override (1-2000)
```

- **Protected branches.** GitGatekeeper never commits on a protected branch, and
  never pushes a protected branch, nor a feature branch whose upstream is a
  protected branch. The cycle is skipped and logged (`protected-branch`), and
  your files are left untouched. Work on a feature branch, or set
  `protected_branches: []` to switch the protection off. `gitgatekeeper status`
  shows the current branch (with `↑N` for unpushed commits) and marks
  protected ones. Run `gitgatekeeper check` once before turning `auto_push` on.
- **Split commits.** One cycle can produce several commits: each module's code
  together with its tests, then documentation, then build/configuration files.
  Each commit gets its own message. If a group cannot be committed (for example
  a possible secret), the cycle stops there and the remaining files are retried
  next time. When there would be more than six groups (typical of layered
  folders such as `Models/`, `Actions/`), GitGatekeeper falls back to broad areas:
  database, code, tests, docs, config. A single group means one commit.

### End-of-day commit

Once a day, at `daily_commit_time` (local time, default `23:55` so the commit
still lands on the day it is for), GitGatekeeper looks at every project and runs the
normal commit cycle for those that:

- have pending changes,
- were worked on today (activity seen while GitGatekeeper ran, or a changed file
  written today),
- have no GitGatekeeper commit yet today,
- are not on a protected branch.

Everything else applies as always: split commits, the file limit, the secret
scan and `auto_push`. It is on by default; set `daily_commit: false` globally or
per project to turn it off. Apply a change to a running service with
`gitgatekeeper reload` (see [Reloading the configuration](#reloading-the-configuration)).

### Approving commits

With `require_approval: true` (globally or per project) GitGatekeeper does all the
work of a normal cycle (the same checks, the same message, the same split into
groups) but stops short of committing. The prepared commits wait in the local
history database:

```bash
gitgatekeeper pending --files      # what is waiting, with the files of each
gitgatekeeper approve 3            # commit proposal #3
gitgatekeeper approve --all        # commit everything that waits, oldest first
gitgatekeeper reject 4             # discard proposal #4; the files stay as they are
```

What approving guarantees:

- The commit is made only if the files are **byte-for-byte what was proposed**
  and the repository is on the **same branch**. Otherwise nothing is committed
  and the proposal is closed as stale; GitGatekeeper prepares a new one at the next
  cycle.
- The commit message is the one you were shown.
- Every guard still applies at approval time: protected branches, the secret
  scan, conflict markers and the repository lock. Your own staged files are left
  alone.
- If `auto_push` is on for the project, approving also pushes, with the usual
  push rules.

A rejection holds until the files change: the same change set is not proposed
again. Committing by hand closes the matching proposal on its own. Nothing is
ever committed without your decision on a project that requires approval,
including the end-of-day commit. `gitgatekeeper status` tells you when commits are
waiting. Apply a change to `require_approval` with `gitgatekeeper reload`.

### Conflict markers

A file whose staged lines contain a `<<<<<<<` ... `>>>>>>>` block is never
committed (`blocked`, with `path:line`): that is an unresolved merge or stash
conflict. Resolve the file and the next cycle commits it.

### Secret scan and false positives

Before every commit GitGatekeeper scans the added lines. Well-known token formats
(AWS, GitHub, Slack, private keys, URLs with passwords) and secret-looking file
names always stop the cycle, and so does a hard-coded `password = "..."`-style
assignment. The log says where to look (`path:line (rule)`), never the value.

If a file legitimately holds example or test values (a README with a `curl`
sample, a test factory), list it for that project:

```yaml
projects:
  - name: my-project
    path: /home/you/projects/my-project
    secret_scan_allow:
      - README.md
      - "api/*/Factories/*.php"
      - tests/                 # a trailing slash means "everything below"
```

This relaxes only the `password = "..."` heuristic in those files. Real token
formats, credentials in URLs and sensitive file names are still checked there.

Only the first 2000 added lines of a file are scanned, and a file longer than
that is not committed (`unverifiable-content`). Generated dependency lockfiles
(`package-lock.json`, `composer.lock`, `yarn.lock`, `Cargo.lock`...) are the
exception: what can be read is still scanned, and the rest is let through.

URLs with credentials are judged on their own. These never count as secrets:
a placeholder or stock password (`password`, `postgres`, `changeme`, `${TOKEN}`,
`<password>`...) and, inside `.env.example`-style templates only, a password on
a local host (`localhost`, `127.0.0.1`, `host.docker.internal` or a bare service
name such as `db`). A real-looking password on a public host stops the cycle
anywhere, templates included.

You rarely need to edit it by hand: `gitgatekeeper add <path>` registers a repository.
Keep your real `config/projects.yaml` out of version control.

### Reloading the configuration

After editing the file (or after `gitgatekeeper add`, `remove`, `enable`, `disable`),
tell the running service to re-read it, without stopping:

```bash
gitgatekeeper reload
```

- A file that cannot be read, or that enables no project, is **refused**: the
  running configuration stays in force and the command exits 1 with the reason.
- A change of settings only (`auto_push`, `require_approval`, protected
  branches, limits...) applies at once and does not interrupt the watchers.
- Adding, removing or moving a project, or changing an inactivity window,
  restarts the watchers. A commit cycle that is running finishes first; the
  history, the waiting approvals and the push retries are kept.
- If the new watchers cannot start, the previous configuration is restored.
- It works through `SIGUSR1`, sent only to a process that is verifiably
  GitGatekeeper. A service started before this feature existed does not know the
  signal and would be killed by it, so `gitgatekeeper reload` refuses and asks you to
  restart it once.

State (database, logs, locks, pid file) lives in `$GITGATEKEEPER_STATE_DIR`, else
`$XDG_STATE_HOME/gitgatekeeper`, else `~/.local/state/gitgatekeeper`. Every command that
needs it also accepts `--state-dir`.

### Taking a commit back

```bash
gitgatekeeper undo my-project        # shows the commit and asks first
```

`undo` removes the last commit GitGatekeeper made in that project from the
branch and leaves **every file exactly as it is**: the changes simply go back to
being unstaged. Under the hood it is `git reset --mixed <parent>`, never
`--hard`. It refuses, and says why, when:

- the commit was already pushed (GitGatekeeper never rewrites published history;
  it points you to `git revert` instead);
- it is no longer the latest commit of the branch;
- you have staged changes of your own, which the reset would drop;
- a merge, rebase, cherry-pick or similar is in progress, or Git is busy;
- GitGatekeeper is in the middle of a cycle on that repository (try again).

The same set of changes is **not committed again automatically**; once you edit
the files, the new version is committed after the usual inactivity. The undone
commit stays in Git's reflog, and `undo` prints the command that puts it back
(`git reset <oid>`). `gitgatekeeper history` shows it as undone.

## Command line

| Command | What it does |
| --- | --- |
| `gitgatekeeper version` | Print the version. |
| `gitgatekeeper projects` | List registered projects and whether each path is a valid repository. |
| `gitgatekeeper init [--root PATH]... [--depth N] [--yes]` | First-time setup: find repositories under your code folders and register the ones you choose. |
| `gitgatekeeper migrate` | Copy your configuration and history from the old name (GitPilot). Copies only; never deletes. |
| `gitgatekeeper add <path> [--name N]` | Register the repository that contains `<path>`. |
| `gitgatekeeper remove <name>` | Unregister a project. The repository is never touched. |
| `gitgatekeeper enable <name>` | Turn monitoring of a project on. |
| `gitgatekeeper disable <name>` | Turn monitoring of a project off. |
| `gitgatekeeper profile <name> [-p FILE]` | Show how GitGatekeeper sees a project's architecture, and which module a file belongs to. |
| `gitgatekeeper start` | Run in the foreground until Ctrl+C or `gitgatekeeper stop`. |
| `gitgatekeeper stop` | Ask the running instance to stop (SIGTERM only, never SIGKILL). |
| `gitgatekeeper check [name] [--offline]` | Read-only readiness check per project: Git identity, protected branch, upstream, `auto_push`, commits behind/ahead, each problem with the command that fixes it. Also asks the remote once (`git ls-remote`, never prompting) whether it is reachable and accepts you; `--offline` skips that. Exits 1 on a blocking problem. |
| `gitgatekeeper reload [--timeout S]` | Make the running service re-read its configuration without a restart. An invalid file is refused and the old configuration stays. |
| `gitgatekeeper status` | Whether it is running, and per project: state, idle time, time to next cycle, pending files, last commit. |
| `gitgatekeeper history [-p NAME] [-n N] [--files]` | Commits GitGatekeeper made, and whether each was pushed. |
| `gitgatekeeper pending [-p NAME] [--files]` | Commits prepared and held for your approval (see [Approving commits](#approving-commits)). |
| `gitgatekeeper approve <id>... \| --all [-p NAME]` | Commit what was prepared, if the files are still exactly as proposed. |
| `gitgatekeeper reject <id>... \| --all [-p NAME]` | Discard prepared commits. Your files are not touched. |
| `gitgatekeeper service install [--no-start] [--force]` | Install and enable GitGatekeeper as a systemd user service (see [below](#running-as-a-systemd-user-service)). |
| `gitgatekeeper service uninstall` | Stop, disable and remove that service. |
| `gitgatekeeper service status` | Whether the service is installed, enabled and running. |
| `gitgatekeeper undo <project> [--yes]` | Take back the last commit GitGatekeeper made in a project; your files are left exactly as they are. Refused if it was pushed (see [Taking a commit back](#taking-a-commit-back)). |
| `gitgatekeeper logs [-p NAME] [--kind commit\|push] [-n N] [--raw]` | Recent cycle events; `--raw` tails the JSON log file. |

`start` runs in the foreground on purpose. To keep it running in the background
use a supervisor such as systemd (below). Only one instance can run per state
directory.

## Running on Ubuntu

```bash
cd ~/Agents/GitGatekeeper
source .venv/bin/activate

gitgatekeeper add ~/projects/my-project
gitgatekeeper projects
gitgatekeeper start          # leave it running in a terminal
```

In another terminal:

```bash
gitgatekeeper status
gitgatekeeper history
gitgatekeeper stop
```

Try it on a throwaway repository first.

## Running as a systemd user service

The easy way, after `gitgatekeeper init`:

```bash
gitgatekeeper service install     # writes ~/.config/systemd/user/gitgatekeeper.service, enables and starts it
gitgatekeeper service status
gitgatekeeper service uninstall   # stops, disables and removes it
```

`install` uses the `gitgatekeeper` executable of the environment you run it from and
the configuration file in use, both as absolute paths, so run it with your
virtualenv active. It writes only that one file under your own config directory
(`$XDG_CONFIG_HOME/systemd/user`) and calls only `systemctl --user`. It refuses
to replace a different unit unless you add `--force`, and refuses to start while
a foreground `gitgatekeeper start` is running (stop it first or use `--no-start`).
If it finds your desktop's SSH agent socket it adds `SSH_AUTH_SOCK` to the unit.
It never changes anything system-wide. After you change the configuration, use
`gitgatekeeper reload`; after upgrading GitGatekeeper, run `gitgatekeeper service install
--force` only if the executable path changed.

To manage the unit by hand instead, GitGatekeeper ships a template,
[`deploy/systemd/gitgatekeeper.service`](https://github.com/robertofilho0/GitGatekeeper/blob/main/deploy/systemd/gitgatekeeper.service):

```bash
mkdir -p ~/.config/systemd/user
cp deploy/systemd/gitgatekeeper.service ~/.config/systemd/user/gitgatekeeper.service
$EDITOR ~/.config/systemd/user/gitgatekeeper.service   # check the two paths

systemctl --user daemon-reload
systemctl --user enable --now gitgatekeeper.service
systemctl --user status gitgatekeeper.service
```

To stop and remove it by hand:

```bash
systemctl --user disable --now gitgatekeeper.service
rm ~/.config/systemd/user/gitgatekeeper.service
systemctl --user daemon-reload
```

Notes:

- By default a user service runs only while you are logged in. To keep it running
  without a login session, run `loginctl enable-linger $USER` yourself; GitGatekeeper
  never does that.
- GitGatekeeper writes its own JSON log (`gitgatekeeper logs --raw`), so `journalctl
  --user -u gitgatekeeper` shows little more than start and stop.
- Pushing over SSH needs a key GitGatekeeper can use without a prompt. GitGatekeeper never
  asks for passwords and never changes your authentication setup. Either use a
  key without a passphrase for that remote, or uncomment the `SSH_AUTH_SOCK`
  line in the unit that matches your desktop's SSH agent (`service install`
  already does this when it finds the socket).
- On stop, systemd sends SIGTERM and waits up to 60 seconds before escalating, so
  a commit in progress can finish.

## Security model

These rules are enforced in code and covered by tests. They are not settings.

**Git operations**

- Never runs `git reset --hard`, `git clean` or `git push --force` (no `+` in
  the push refspec either), and never overwrites existing changes.
- Never runs a commit during a merge, rebase, cherry-pick, revert or bisect, on
  a detached HEAD, with conflicts, or while an `index.lock` exists.
- Never creates empty commits.
- Verifies repository state before and after every Git operation. If the state
  changed underneath it, it rolls back its own staging and stops.
- Respects `.gitignore`.

**Your work stays yours**

- Files you staged yourself (including partially staged files) are never added
  to a GitGatekeeper commit, and stay staged afterwards.
- GitGatekeeper commits only paths it selected, using literal pathspecs, so unusual
  file names cannot widen a commit.
- It does not assume every change in a repository belongs to it. When it cannot
  separate its changes safely, it skips the cycle and records the reason.

**Secrets**

- Files that commonly hold secrets (`.env`, private keys, tokens, credentials,
  cloud and SSH config...) are never selected.
- Added lines are scanned for credential patterns. A match aborts the whole
  cycle and the finding is recorded, without its value.
- Content that cannot be verified (too large, unreadable) is not committed.

**Push**

- Off by default (`auto_push: false`); enabled per project or globally.
- Pushes only the current branch to its already configured upstream. It never
  creates an upstream, and skips when there is none or when the branch is behind.
- Pushes only commits GitGatekeeper itself recorded. Your own unpublished commits are
  never published by it.
- Never changes your Git or SSH authentication configuration and never prompts.
  If a push fails, the local commit is kept.
- Credentials embedded in URLs are masked in logs and errors.

**Process**

- No `shell=True`; every external process has a timeout.
- One lock per repository; a separate lock for push.
- Duplicate-commit protection through a content fingerprint.
- Single instance per state directory; `stop` signals only a process that holds
  the instance lock and looks like GitGatekeeper.
- State, log and database files are private (`0600`, directories `0700`).

## Commit messages

Messages follow Conventional Commits: `type(scope): subject`, plus a body that
lists what changed in each file. They are built from what the diff and the code
actually show, never from guesses:

- **What changed.** For source files GitGatekeeper finds the functions, classes and
  methods that contain the changed lines (`Cart.total`), for stylesheets the
  selectors (`heatmap`, `stats`), and for Markdown the sections you edited.
- **Where it changed.** The scope is the module that owns most of the change
  (`feat(activity): ...`). Modules are detected from your project's layout, for
  example `src/<package>/<module>/` in Python, or `ActivityService.php` giving
  `activity`.
- **Why (type).** `feat`, `fix`, `refactor`, `docs`, `test`, `style`, `perf`,
  `build`, `ci` or `chore`, from the kinds of files, the structure of the change
  and keywords. Every decision and its confidence are stored with the commit.

Examples of what you get:

```
feat(activity): add ActivityService and JsonStore

- added src/ActivityService.php (+203/-0): ActivityService, setDone, doneOn, grid
- added src/JsonStore.php (+129/-0): JsonStore, read, update
- modified style.css (+89/-2): heatmap, stats, shift

docs: document Testes and Calendário de constância section
fix(core): update ActivityService.streaks
```

When nothing specific can be said, the message stays plain rather than invented.
Secret files and lines are never read into a message.

### Telling GitGatekeeper about your architecture (optional)

Detection works without any setup. To name modules yourself, add a `modules`
block to a project in `projects.yaml` (folder prefixes or globs, relative to the
repository). The first matching module wins:

```yaml
projects:
  - name: shop
    path: /home/you/shop
    modules:
      payments: [src/billing, "app/**/*Invoice*.php"]
      ui: [assets/css, resources/views]
```

Check what GitGatekeeper understood with:

```bash
gitgatekeeper profile shop -p src/billing/tax.py -p assets/css/site.css
```

## Data and logs

- `gitgatekeeper.db`: SQLite (WAL). Tables `commits` and `events`; old events are
  pruned automatically.
- `logs/gitgatekeeper.log`: JSON lines, rotated (5 MB x 3).
- `status.json`: live snapshot used by `gitgatekeeper status`; removed on stop.
- `locks/`, `gitgatekeeper.pid`: coordination files.

## Tests

```bash
source .venv/bin/activate
ruff check .
ruff format --check .
pytest -q
pytest --cov=gitgatekeeper --cov-report=term-missing   # coverage
```

Tests use temporary directories and isolated repositories with a hermetic Git
environment. They never touch your real repositories or your GitGatekeeper state.

Some tests guard the project's promises: no module may import network libraries,
runtime dependencies are limited to `watchdog`, `pydantic`, `pyyaml`, `typer` and
`rich`, and only the push engine (`git push`) and `gitgatekeeper check` (`git ls-remote`,
read-only) may talk to a remote.

## Known limitations

- A push that failed because of the network or a timeout is retried after 1, 5,
  15 and then every 30 minutes (six retries); other failures (rejected, auth,
  behind upstream) are not retried until the next cycle or restart.
- Approval is local: there is no e-mail or phone notification for waiting
  commits yet; look at `gitgatekeeper pending` or `gitgatekeeper status`.
- If the process dies between creating a commit and recording it, that commit is
  left unrecorded. GitGatekeeper will never push such a commit.
- Idle time and countdowns in `gitgatekeeper status` exist only while the service runs.
- Linux only.

## Roadmap

- A command to preview what the next commit of a project would contain.
- More languages in the code-context analysis (Java, C#, Ruby, Kotlin...).
- Tests and fixes for worktrees, submodules, Git LFS and very large repositories.
- macOS and Windows support.
- Desktop notifications.

## Releasing

Every push and pull request runs `ruff`, the format check and the tests on
Python 3.12 and 3.13, builds the package, checks it with `twine check --strict`
and installs the wheel in a clean environment (`.github/workflows/ci.yml`).

Releases are published to [PyPI](https://pypi.org/project/gitgatekeeper/) by
`.github/workflows/release.yml` using Trusted Publishing: there is no API token
or secret in the repository. Pushing a tag builds and checks the package, then
waits for the maintainer's approval before uploading it.

```bash
# 1. set `version` in pyproject.toml, update CHANGELOG.md, commit and push
# 2. tag it; the tag must match the version, or the workflow stops
git tag -a v0.1.1 -m "v0.1.1" && git push origin v0.1.1
# 3. approve the upload under Actions, then create the GitHub release
gh release create v0.1.1 --title "v0.1.1" --notes-file CHANGELOG.md
```

A manual run of the workflow (Actions > Release > Run workflow) uploads the same
files to TestPyPI instead, to rehearse a release.

## Similar projects

Other tools also commit automatically. These descriptions are the projects' own
one-line summaries as listed when this was written; read their pages for the
current picture.

- `gitpilot-ai`: "Local AI-powered Git auto-committer daemon".
- `smart-autocommit`: "deterministic gates decide what may enter history; the LLM
  only writes messages and researches unknown paths, and never blocks a commit".
- `git-worklog`: generates worklogs, reports and changelogs from Git history.

GitGatekeeper's emphasis is different: the messages come from rules rather than a
language model, everything stays on your machine, and the safety model is the
point (protected branches, secret scan, an approval queue, `undo`, and nothing
destructive).

## Contributing

See [CONTRIBUTING.md](https://github.com/robertofilho0/GitGatekeeper/blob/main/CONTRIBUTING.md) for the setup, the checks every change
must pass and the rules that do not bend, [SECURITY.md](https://github.com/robertofilho0/GitGatekeeper/blob/main/SECURITY.md) to report a
vulnerability privately, and the [Code of Conduct](https://github.com/robertofilho0/GitGatekeeper/blob/main/CODE_OF_CONDUCT.md). Changes
that weaken a rule in the [Security model](#security-model) will not be accepted
without a very good reason and a test proving the new behaviour is safe.

## License

[MIT](https://github.com/robertofilho0/GitGatekeeper/blob/main/LICENSE).
