No description
  • Rust 97%
  • Shell 2.9%
Find a file
microchipster f04e058aff readme update
2026-01-08 16:21:31 -08:00
src readme 2026-01-02 14:18:55 -08:00
tests init 2026-01-02 13:36:53 -08:00
.gitignore init 2026-01-02 13:36:53 -08:00
AGENTS.md readme 2026-01-02 14:18:55 -08:00
Cargo.toml init 2026-01-02 13:36:53 -08:00
install init 2026-01-02 13:36:53 -08:00
LICENSE init 2026-01-02 13:36:53 -08:00
Makefile init 2026-01-02 13:36:53 -08:00
README.md readme update 2026-01-08 16:21:31 -08:00
rust-toolchain.toml init 2026-01-02 13:36:53 -08:00
test init 2026-01-02 13:36:53 -08:00
uninstall init 2026-01-02 13:36:53 -08:00

mtime

mtime is a small Rust CLI that reports file modification times by scanning the filesystem and optionally preferring Git history when determining the newest/oldest timestamps.

Installation

  • Ensure Rust toolchain is installed and matches rust-toolchain.toml (stable + rustfmt/clippy).
  • Run ./install to build the release binary (it prefers a musl target and falls back to the host if the cross toolchain is unavailable). Override the target with TARGET=<triple> or ./install --target <triple>.
  • Use ./uninstall to drop /usr/local/bin/mtime.
  • There is also a Makefile that proxies: make install, make uninstall, make clean, and make test.

Usage

mtime [OPTIONS] [PATHS...]
  • Without arguments, scans the current directory.
  • --git / --hybrid: prefer Git commit timestamps (hybrid uses filesystem mtimes for dirty files).
  • --clean-git: fail when the repository is dirty.
  • --include-vcs-dirs: recurse into .git/.hg/.svn directories (with deterministic extra scans to survive coverage builds).
  • --ignore-gitignore: skip .gitignore filtering; useful for cross-repo comparisons.
  • --newest-time/file, --oldest-time/file: limit output to the single newest/oldest file/time.

Examples

Scan the current directory with filesystem mtimes

mtime

By default it walks the current directory and reports the newest and oldest files that it finds using filesystem mtimes, so you can rerun the same command whenever you want a quick health check.

Prefer Git timestamps but fall back on dirty files

mtime --hybrid --newest-time/file src

Hybrid mode prefers commit timestamps for tracked files but still uses filesystem mtimes when the worktree is dirty; --newest-time/file shows you the single file with the latest commit (or mtime for dirty entries) inside src.

Include VCS directories when you need every tracked entry

mtime --include-vcs-dirs --oldest-time

Recurse into .git, .hg, and .svn trees to confirm repository metadata stays fresh; deterministic pre/post scans keep coverage builds stable even though WalkDir normally skips them.

Compare multiple roots while ignoring .gitignore

mtime --ignore-gitignore tooling/sandbox docs

Drop gitignore filtering so you can compare raw mtimes across two directories without being blocked by repository rules, for example when auditing generated files or shared artifacts.

The CLI logic lives in src/main.rs, while src/lib.rs exports the same helpers plus extra unit tests that the coverage-focused tests/ suites consume.

Development

  • ./test executes the full suite: cargo build, cargo test --workspace, installs cargo-llvm-cov if needed, runs cargo llvm-cov (HTML + lcov), and executes the installer to verify the release path. Coverage artifacts land under coverage/rust/ alongside /tmp/rustcov during the run.
  • Unit/integration tests live in src/lib.rs, src/main.rs, and tests/cover_*.rs; they rely heavily on temporary directories, controlled CWD fallbacks, and cross-mode assertions (Git vs filesystem vs hybrid).
  • Keep run_with_args, path resolution, gitignore handling, and the --include-vcs-dirs fallbacks in sync between src/lib.rs and src/main.rs.
  • Follow the existing style: use detailed comments (novice/maintainer/LLM notes), dedupe canonical paths, and prefer helper reuse (get_file_time, scan_vcs_root_and_add_files).

Gotchas

  • Canonicalization is sensitive under instrumented builds: . is preserved as literal when the captured cwd is untrusted, so tests expect the CLI to error rather than accidentally scanning the wrong directory.
  • --include-vcs-dirs triggers special pre-/post-scans (scan_vcs_root_and_add_files) when no repository/gitignore checker exists to keep coverage builds deterministic.
  • The installer cross-build path assumes musl targets exist; missing x86_64-linux-musl-gcc will trigger a fallback to the native host build and emits a warning.

CI notes

  • Coverage results (HTML + lcov + report) are generated via cargo llvm-cov --workspace --all-features inside ./test. The helper also writes coverage/rust/ for easy browsing.
  • RUSTFLAGS='-D warnings' is enforced by the test script, so keep builds clean.