Skip to main content

A Git-based workspace state management system

Project description

git-checkpoint

A Git-based workspace state management system that provides efficient codebase state tracking and restoration capabilities.

How It Works

git-checkpoint uses Git under the hood but operates completely independently from your workspace's version control:

  1. Creates a separate "shadow" Git repository in a temporary directory
  2. Your workspace files are copied to this shadow repository for tracking
  3. All Git operations happen in the shadow repository, never touching your actual workspace's Git state
  4. When restoring checkpoints, files are copied back from the shadow repository
  5. Your workspace's Git repository (if any) remains completely untouched

Features

  • Shadow Git repository management for non-intrusive state tracking
  • Workspace state tracking with commit and restore functionality
  • Efficient diff generation between states
  • Smart handling of large files (LFS)
  • Nested Git repository support
  • Configurable file exclusion patterns

Installation

# Using poetry (recommended)
poetry add git-checkpoint

# Using pip
pip install git-checkpoint

Quick Start

from git_checkpoint import CheckpointTracker

# Initialize tracker (creates shadow repository in temp directory)
tracker = CheckpointTracker.create(
    task_id="my_task",
    workspace_path="/path/to/workspace"
)

# Create a checkpoint (copies current workspace state to shadow repo)
commit_hash = tracker.commit()

# Get changes between checkpoints
diffs = tracker.get_diff_set(
    lhs_hash="previous_hash",
    rhs_hash="current_hash"
)

# Restore to a previous state (copies files back from shadow repo)
tracker.reset_head("previous_hash")

# Clean up shadow repository when done
tracker.cleanup()

Configuration

Create a .checkpointrc file in your workspace:

enabled: true
storage_path: ".checkpoints"
ignore_patterns:
  - "*.pyc"
  - "__pycache__"
  - "node_modules"
  - ".git"

API Reference

CheckpointTracker

Constructor

def __init__(self, task_id: str, workspace_path: str)
  • task_id: Unique identifier for the checkpoint session
  • workspace_path: Path to the workspace to track

Methods

create
@classmethod
def create(cls, task_id: str, workspace_path: str) -> "CheckpointTracker"

Creates and initializes a new checkpoint tracker.

commit
def commit(self) -> Optional[str]

Creates a new checkpoint of the current workspace state. Returns the commit hash.

reset_head
def reset_head(self, commit_hash: str) -> None

Restores the workspace to the state of the specified commit.

get_diff_set
def get_diff_set(
    self,
    lhs_hash: Optional[str],
    rhs_hash: Optional[str]
) -> List[DiffInfo]

Returns a list of file differences between two commits.

Development

# Install dependencies
poetry install

# Run tests
poetry run pytest tests/ -v

# Run tests with coverage
poetry run pytest tests/ -v --cov=git_checkpoint

Error Handling

The package uses custom exceptions for common error cases:

  • WorkspaceError: Invalid workspace configuration
  • GitError: Git operation failures
  • ConfigError: Configuration parsing issues

Best Practices

  1. Always validate workspace paths before initialization
  2. Use meaningful task IDs for better organization
  3. Handle large files appropriately using LFS
  4. Regularly clean up old checkpoints to manage storage

License

MIT License - See LICENSE file for details

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

git_checkpoint-0.1.1.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

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

git_checkpoint-0.1.1-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file git_checkpoint-0.1.1.tar.gz.

File metadata

  • Download URL: git_checkpoint-0.1.1.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.11.6 Darwin/24.1.0

File hashes

Hashes for git_checkpoint-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f323fa175aa5c044e2a67915b195eece228d797139cc684ca13f47cb3f34ff54
MD5 ff919a23da22529936d55c8530bfbbd6
BLAKE2b-256 30370866749ea63caa0c53523e2c30e55c558c7db39a326cabcf5b7998b87e4b

See more details on using hashes here.

File details

Details for the file git_checkpoint-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: git_checkpoint-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.11.6 Darwin/24.1.0

File hashes

Hashes for git_checkpoint-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6af8c14d1ce31a70b02026e58d9ff6aac4094953a684b2126ee01a88d3f56a36
MD5 38c6dcdb885aea0a940778a4666899e7
BLAKE2b-256 afe2ba1ffae536aaa20b8d6de859f0d2f2c31f6b6d8a2170332966cbd7f446ce

See more details on using hashes here.

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