Skip to main content

File state checkpoint tool - has your code tarnished?

Project description

tarnished

File state checkpoint tool - has your code tarnished?

Installation

Using uv (recommended)

uv tool install tarnished

Using pip

pip install tarnished

From source

git clone https://github.com/RasmusGodske/tarnished.git
cd tarnished
uv tool install .

Quick Start

# Initialize .tarnished/ directory
tarnished init

# Save a checkpoint for a profile
tarnished save lint:php "app/**/*.php" "tests/**/*.php"

# Check if files have changed
tarnished check lint:php  # Exit 0 = clean, Exit 1 = tarnished

# See status of all profiles
tarnished status

Usage

Commands

Command Description
tarnished init Initialize .tarnished/ directory
tarnished save <profile> [patterns...] Save checkpoint for profile
tarnished check <profile> Check if profile is tarnished
tarnished status Show JSON status of all profiles

Exit Codes

Code Meaning
0 Clean (no changes)
1 Tarnished (changes detected)
2 Unknown profile

How It Works

tarnished is a simple CLI tool that tracks file state via checksums. It helps you know when code has changed and needs re-checking (linting, testing, etc.).

Core Concepts

  • Profile: A named set of glob patterns (e.g., lint:php tracks app/**/*.php)
  • Checkpoint: A saved checksum representing file state at a specific moment
  • Tarnished: A profile is "tarnished" if files have changed since the last checkpoint

Implementation

tarnished uses file metadata (path + size + mtime) to compute checksums. This is:

  • Git-independent - works regardless of commit history
  • Fast - no file content hashing required
  • Simple - single JSON files for config and state

File Structure

.tarnished/
├── config.json    # Profile patterns (commit this)
└── state.json     # Current checksums (gitignored)

Integration Example

Add to your CI/test scripts:

# After successful test run, save checkpoint
./run-tests.sh && tarnished save tests

# Before committing, check if tests need re-running
if ! tarnished check tests; then
    echo "Tests are tarnished - please run tests first"
    exit 1
fi

Pre-commit Hook

#!/bin/bash
# .git/hooks/pre-commit

# Check if any profiles are tarnished
status=$(tarnished status)
if echo "$status" | grep -q '"status": "tarnished"'; then
    echo "Some profiles are tarnished. Please run the relevant checks."
    tarnished status
    exit 1
fi

CI Pipeline Example

# In your CI workflow
- name: Check code state
  run: |
    tarnished check lint:php || echo "PHP files changed - running linter"
    tarnished check tests || echo "Test files changed - running tests"

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tarnished-0.2.1.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tarnished-0.2.1-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file tarnished-0.2.1.tar.gz.

File metadata

  • Download URL: tarnished-0.2.1.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for tarnished-0.2.1.tar.gz
Algorithm Hash digest
SHA256 4b69b93e3943fb6391bcb398738257c77990596e4288c3582e93b9434a2229ce
MD5 29c94ad0991462b2debe73f1294b8f63
BLAKE2b-256 69f7ab036cb6dba61cc0deb1efcc5ee2ac587a0065f27dd6d7472e47692cd39c

See more details on using hashes here.

Provenance

The following attestation bundles were made for tarnished-0.2.1.tar.gz:

Publisher: publish.yml on RasmusGodske/tarnished

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tarnished-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: tarnished-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for tarnished-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c3079e850d4ee90464173d9d9451faefccae2212670feb9b538a5d9b333bd420
MD5 7906e4cf38fedc22cfd8f7e7125d1478
BLAKE2b-256 a983dd9e33827055278b3fec0f83c3b01519646f2daf856c536b70f2eb2d929a

See more details on using hashes here.

Provenance

The following attestation bundles were made for tarnished-0.2.1-py3-none-any.whl:

Publisher: publish.yml on RasmusGodske/tarnished

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page