Skip to content

JamoBox/mote

Repository files navigation

Mote: Git Auto-Commit File Watcher

Mote is a high-performance, asynchronous file watcher written in Rust. It's designed to monitor one or more directories for file system changes and automatically create Git commits in the corresponding repository when changes are detected.

Features

  • Real-time File Monitoring: Watches specified directories for changes (creations, modifications, deletions).
  • Automatic Git Commits: Automatically stages and commits detected changes to the respective Git repository.
  • History Squashing: Automatically condenses older automated commits into hourly, daily, or weekly summaries to keep your Git history clean.
  • Asynchronous Architecture: Built on tokio for efficient, non-blocking I/O operations.
  • Non-Blocking Git Operations: Utilizes tokio::task::spawn_blocking to ensure CPU-intensive Git operations don't block the main event loop.
  • Configurable: Easy to set up watch directories, logging levels, and squashing policies via a config.toml file.

Getting Started

Prerequisites

Make sure you have Rust and Cargo installed. If not, you can install them via rustup:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Configuration

Before running Mote, you need to create a config.toml file in the project root. This file specifies the desired database path, logging level, and history squashing policies.

Example config.toml:

# The path to the SQLite database (defaults to ~/.mote/mote.db)
database_path = "~/.mote/mote.db"

# Optional: Set the logging level.
# Can be "error", "warn", "info", "debug", or "trace". Defaults to "info".
log_level = "debug"

# Optional: Set the debounce period in milliseconds. 
# Mote will wait this long for filesystem activity to settle before committing.
# Defaults to 1000.
debounce_ms = 1000

# Optional: Custom ignore patterns (glob format).
# Files matching these patterns will NOT trigger auto-commits.
ignore = ["*.tmp", "target/**"]

# Optional: Configure history squashing
[squash_history]
# How old should commits be before they start getting squashed?
# Supports "h" (hours), "d" (days), "w" (weeks).
squash_by_time = "1h"

# How many commits should exist before squashing older ones?
# (e.g., if set to 10, mote will always keep the 10 most recent commits untouched)
squash_by_limit = 10

# How should squashed commits be grouped?
# Options: "hour", "day", "week".
squash_into = "day"

Building and Running

Navigate to the project root directory and use Cargo to build and run Mote:

  • Build the project:

    cargo build
  • Run the application:

    cargo run
  • Run in release mode (for performance):

    cargo run --release

Development Conventions

  • Asynchronous Rust: The application leverages the tokio runtime for all I/O-bound tasks.
  • Non-Blocking Git Operations: All git2 operations are wrapped in tokio::task::spawn_blocking to prevent blocking the main event loop.
  • Logging: env_logger is used for flexible logging, configurable via config.toml or RUST_LOG.

License

See LICENSE

About

Mote: Auto-commit file changes to Git, effortlessly.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors