bitcache is a complete Rust-based command-line tool for managing binary files (bitstreams) in git repositories using MD5-based tracking.
- Language: Rust (edition 2021)
- CLI Framework: clap 4.5 with derive macros
- Serialization: serde + serde_json
- MD5: md5 crate
- Temporary files: tempfile crate
- Timestamps: chrono crate
The tool implements exactly the specifications requested:
- ✅ Language: Rust
- ✅ Subcommands:
publishandget - ✅ Publish arguments:
--repo: Git repository URL--source: Source file for MD5 computation--bitstream: Binary file to upload--path: Target directory in repository--ssh-key(optional): SSH private key for git operations
- ✅ Get arguments:
--repo: Git repository URL--md5: MD5 hash to lookup--ssh-key(optional): SSH private key for git operations
- ✅ Publish workflow:
- Computes MD5 of source file
- Uploads binary to repository at given path
- Updates metadata
- ✅ Metadata: JSON file (
bitcache_metadata.json) at repository root - ✅ Get workflow:
- Reads metadata
- Copies binary corresponding to MD5 to current directory
- ✅ Git operations: All repository operations use git commands
- MD5-based tracking: Each binary is linked to its source via MD5 hash
- Git integration: Fully automated git clone, commit, and push operations
- SSH key support: Optional custom SSH private key for git authentication
- Metadata management: JSON file maintains complete tracking information
- Timestamping: Records when each binary was published
- Temporary directories: Automatically cleaned up after operations
- Error handling: Comprehensive error messages for common issues
bitcache/
├── Cargo.toml # Dependencies and project metadata
├── README.md # Comprehensive documentation
├── CONTRIBUTING.md # Contribution guidelines
├── LICENSE # MIT License
├── .gitignore # Git ignore rules
├── examples/
│ └── usage_example.sh # Example usage script
└── src/
└── main.rs # Complete implementation (~400 lines)
- Cargo.toml - Project configuration with all required dependencies
- src/main.rs - Complete implementation with:
- CLI structure using clap
- Metadata structure with serde
- MD5 computation function
- Git repository operations
- publish subcommand handler
- get subcommand handler
- README.md - Extensive documentation including:
- Overview and features
- Installation instructions
- Usage examples
- Metadata format
- Workflow diagrams
- Troubleshooting guide
- CONTRIBUTING.md - Guidelines for contributors
- examples/usage_example.sh - Executable example script
The tool maintains a bitcache_metadata.json file in the repository:
{
"entries": {
"md5_hash_here": {
"md5": "md5_hash_here",
"binary_path": "relative/path/to/binary.bit",
"source_file": "original_source.vhd",
"timestamp": "2025-12-11T10:30:00Z"
}
}
}# Basic usage
bitcache publish \
--repo git@github.com:myorg/bitstreams.git \
--source design.vhd \
--bitstream output.bit \
--path builds/v1.0
# With custom SSH key
bitcache publish \
--repo git@github.com:myorg/bitstreams.git \
--source design.vhd \
--bitstream output.bit \
--path builds/v1.0 \
--ssh-key ~/.ssh/deploy_keyWhat happens:
- Computes MD5 of
design.vhd - Clones repository to temp directory
- Copies
output.bittobuilds/v1.0/ - Updates metadata with MD5 → binary mapping
- Commits and pushes to repository
# Basic usage
bitcache get \
--repo git@github.com:myorg/bitstreams.git \
--md5 a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6
# With custom SSH key
bitcache get \
--repo git@github.com:myorg/bitstreams.git \
--md5 a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6 \
--ssh-key ~/.ssh/deploy_keyWhat happens:
- Clones repository to temp directory
- Reads metadata file
- Finds binary for given MD5
- Copies binary to current directory
Similar to bmregression but focused on binary caching:
| Feature | bmregression | bitcache |
|---|---|---|
| Purpose | Regression testing | Binary caching |
| Operations | run, list, describe, reset, diff | publish, get |
| Tracking | YAML configs + expected outputs | JSON metadata + MD5 hashes |
| Git usage | Clone repos for testing | Clone repos for storage |
| Language | Rust | Rust |
| CLI framework | clap | clap |
✅ Build: Successfully compiles in release mode ✅ Dependencies: All dependencies resolved ✅ Help system: Working CLI with comprehensive help ✅ Structure: Clean, modular code with documentation
- Set up a git repository for storing bitstreams
- Configure git authentication (SSH keys or tokens)
- Build the tool:
cargo build --release - Test with your files: Use the example script as a template
- Integrate into workflow: Add to build scripts or CI/CD
- Git access is handled externally (as requested)
- The tool assumes git authentication is already configured
- Temporary directories are automatically cleaned up
- All operations are atomic (clone, modify, push)
- No local state is maintained (stateless operation)
The tool is complete and ready to use. Simply:
- Build it:
cargo build --release - The binary is at:
target/release/bitcache - Copy to PATH or use directly
- Start publishing and retrieving bitstreams!