Add git database locks and db_dir config#307
Open
micprog wants to merge 4 commits into
Open
Conversation
Modeled on memora-rs's RAII flock pattern: introduces an `FsLock` guard in `src/lock.rs` backed by `fs4`, and takes a per-`(name, url)` exclusive lock under `<database>/git/locks/` around `git_database` and `checkout_git`. Locks released automatically on drop (and by the kernel on crash). `clone` and `snapshot` subcommands intentionally remain unguarded. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds an optional `db_dir` config field that overrides only the bare-repo and lock-file locations (`<db_dir>/git/db/` and `<db_dir>/git/locks/`), while working-tree checkouts and everything else continue to derive from `database`. This lets a single shared config enable cross-project cache sharing without forcing same-named projects to commit a `workspace.checkout_dir` in their `Bender.yml`. The field is purely additive and unknown to older Bender versions, which silently ignore it and fall back to their per-project default — strictly safer than today's shared-`database:` recipe in mixed-version setups. Docs updated: `book/src/configuration.md` documents the new field; `book/src/workflow/ci.md` rewrites the shared-cache recipe around `db_dir` and retires the now-fixed concurrent-runs caveat; `book/src/local.md` mentions it in the example block. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- src/progress.rs: collapse nested `if self.git_op == Submodule { ... }`
blocks into match guards on the relevant arms; the existing `_ => {}`
wildcard now handles the non-submodule case.
- src/config.rs: collapse the inner glob/non-glob `if` in `glob_file`
into a match guard; the pre-existing `_ => Ok(vec![self])` arm covers
the fall-through.
- Drop redundant `.into_iter()` on values passed to `.chain()`
in `src/sess.rs`, `src/src.rs`, and `src/config.rs`.
- tests/cli_regression.rs: pass an array directly to `Command::args`
instead of borrowing it.
`cargo clippy --all-targets -- -D warnings` is clean; `cargo test`
unchanged.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Honoured only when no configuration file sets `db_dir`; any `Bender.local`/`.bender.yml`/user/system config still wins. Empty strings are treated as unset. Lets a CI runner export the shared cache path once instead of maintaining a `Bender.local` next to every project. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
git_databaseandcheckout_gitin a cross-processflock(fs4) keyed per dependency, so concurrentbenderinvocations against the same dep serialize safely. Locks live at<database>/git/locks/and are released by the kernel on process exit.db_dirconfig field: new optional setting that overrides only the bare-repo and lock paths, leaving checkouts underdatabase. Lets a single sharedBender.localenable cross-project cache reuse without forcing per-projectworkspace.checkout_dir. Older bender versions silently ignore the field and fall back to per-project caches — safer than the legacydatabase:-only sharing recipe in mixed-version setups.collapsible_match, redundant.into_iter(),args(&[...])).cargo clippy --all-targets -- -D warningsnow passes.Docs updated:
configuration.md(newdb_direntry),workflow/ci.md(db_diris now the recommended sharing recipe; retires the concurrent-runs caveat),local.md,CHANGELOG.md.