- Rust 97%
- Shell 2.9%
| src | ||
| tests | ||
| .gitignore | ||
| AGENTS.md | ||
| Cargo.toml | ||
| install | ||
| LICENSE | ||
| Makefile | ||
| README.md | ||
| rust-toolchain.toml | ||
| test | ||
| uninstall | ||
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
./installto build the release binary (it prefers a musl target and falls back to the host if the cross toolchain is unavailable). Override the target withTARGET=<triple>or./install --target <triple>. - Use
./uninstallto drop/usr/local/bin/mtime. - There is also a
Makefilethat proxies:make install,make uninstall,make clean, andmake 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/.svndirectories (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
./testexecutes the full suite:cargo build,cargo test --workspace, installscargo-llvm-covif needed, runscargo llvm-cov(HTML + lcov), and executes the installer to verify the release path. Coverage artifacts land undercoverage/rust/alongside/tmp/rustcovduring the run.- Unit/integration tests live in
src/lib.rs,src/main.rs, andtests/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-dirsfallbacks in sync betweensrc/lib.rsandsrc/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-dirstriggers 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-gccwill 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-featuresinside./test. The helper also writescoverage/rust/for easy browsing. RUSTFLAGS='-D warnings'is enforced by the test script, so keep builds clean.