refactor: collapse the _with/repo twin API on the meta-ref data modules
commit
a7a73fbrefactor: collapse the _with/repo twin API on the meta-ref data modules
Each data module exposed every operation twice — a foo_with(store) and a
foo(repo) wrapper that just opened a store and delegated. Only four _with
variants have external (server) callers; the rest were pure boilerplate. Fold
the store-open into the single repo-path function and keep only the batched
loaders the server reuses. No behavior change; ~185 fewer lines.
refactor: keep only members::{load_with,load_all_with}, revocations::fingerprints_with, config::load_with as store-taking variants refactor: fold issues::promote_with into promote, preserving its single-store counter CAS Assisted-by: Claude:claude-opus-4-8
Reviews
No reviews of this commit yet — record a verdict below.
Start a review
crates/git-ents/src/account.rs
@@ -29,36 +29,19 @@
pub created_at: u64,
}
-/// Load the account profile at [`ACCOUNT_REF`] from an already-open `store`,
-/// or `None` when the ref is absent — i.e. when the repository is not an
-/// account repo.
-pub fn load_with(store: &git_store::Store) -> Result<Option<Account>, git_store::Error> {
- store.load::<Account>(ACCOUNT_REF)
-}
-
-/// Load the account profile at [`ACCOUNT_REF`] in `repo`. See [`load_with`].
+/// Load the account profile at [`ACCOUNT_REF`] in `repo`, or `None` when the
+/// ref is absent — i.e. when the repository is not an account repo.
pub fn load(repo: &Path) -> Result<Option<Account>, git_store::Error> {
- load_with(&git_store::Store::open(repo)?)
+ git_store::Store::open(repo)?.load::<Account>(ACCOUNT_REF)
}
-/// Write `account` to [`ACCOUNT_REF`] through an already-open `store`,
-/// replacing any existing value as a new commit.
-pub fn store_with(store: &git_store::Store, account: &Account) -> Result<(), git_store::Error> {
- store.store(ACCOUNT_REF, account, "Update account")
-}
-
-/// Write `account` to [`ACCOUNT_REF`]. See [`store_with`].
+/// Write `account` to [`ACCOUNT_REF`] in `repo`, replacing any existing value
+/// as a new commit.
pub fn store(repo: &Path, account: &Account) -> Result<(), git_store::Error> {
- store_with(&git_store::Store::open(repo)?, account)
+ git_store::Store::open(repo)?.store(ACCOUNT_REF, account, "Update account")
}
-/// Whether an already-open `store` is an account repo — whether it carries
-/// [`ACCOUNT_REF`].
-pub fn is_account_repo_with(store: &git_store::Store) -> Result<bool, git_store::Error> {
- Ok(load_with(store)?.is_some())
-}
-
-/// Whether `repo` is an account repo. See [`is_account_repo_with`].
+/// Whether `repo` is an account repo — whether it carries [`ACCOUNT_REF`].
pub fn is_account_repo(repo: &Path) -> Result<bool, git_store::Error> {
Ok(load(repo)?.is_some())
}
crates/git-ents/src/checks.rs
@@ -57,8 +57,8 @@
/// An absent ref yields an empty set, as on a server whose check set has not
/// been pushed yet. A present but unreadable ref is an error so callers can
/// distinguish corruption from "no checks configured".
-pub fn load_with(store: &git_store::Store) -> Result<Vec<Check>, git_store::Error> {
- Ok(store
+pub fn load(repo: &Path) -> Result<Vec<Check>, git_store::Error> {
+ Ok(git_store::Store::open(repo)?
.load::<Checks>(CHECKS_REF)?
.map(|doc| {
doc.checks
@@ -72,15 +72,9 @@
.unwrap_or_default())
}
-/// Load the configured checks recorded at [`CHECKS_REF`] in `repo`. See
-/// [`load_with`].
-pub fn load(repo: &Path) -> Result<Vec<Check>, git_store::Error> {
- load_with(&git_store::Store::open(repo)?)
-}
-
-/// Write `checks` to [`CHECKS_REF`] through an already-open `store`, replacing
-/// any existing set as a new commit.
-pub fn store_with(store: &git_store::Store, checks: &[Check]) -> Result<(), git_store::Error> {
+/// Write `checks` to [`CHECKS_REF`] in `repo`, replacing any existing set as a
+/// new commit.
+pub fn store(repo: &Path, checks: &[Check]) -> Result<(), git_store::Error> {
let doc = Checks {
checks: checks
.iter()
@@ -95,12 +89,7 @@
})
.collect(),
};
- store.store(CHECKS_REF, &doc, "Update checks")
-}
-
-/// Write `checks` to [`CHECKS_REF`]. See [`store_with`].
-pub fn store(repo: &Path, checks: &[Check]) -> Result<(), git_store::Error> {
- store_with(&git_store::Store::open(repo)?, checks)
+ git_store::Store::open(repo)?.store(CHECKS_REF, &doc, "Update checks")
}
/// The namespace under which a commit's check runs are recorded: one ref,
@@ -165,60 +154,42 @@
pub runs: Vec<Run>,
}
-/// Record a run of `outcomes` for `commit` through an already-open `store`, as
-/// a new commit on `refs/meta/runs/<commit>`, parented on the prior run so the
-/// ref's commit chain is the run history. The commit's date is the run time.
-pub fn record_with(
- store: &git_store::Store,
- commit: &str,
- outcomes: &[RunOutcome],
-) -> Result<(), git_store::Error> {
- store.store(
+/// Record a run of `outcomes` for `commit` in `repo`, as a new commit on
+/// `refs/meta/runs/<commit>`, parented on the prior run so the ref's commit
+/// chain is the run history. The commit's date is the run time.
+pub fn record(repo: &Path, commit: &str, outcomes: &[RunOutcome]) -> Result<(), git_store::Error> {
+ git_store::Store::open(repo)?.store(
&format!("{RUNS_NS}/{commit}"),
&run_doc(outcomes),
"Record check run",
)
}
-/// Record a run of `outcomes` for `commit` in `repo`. See [`record_with`].
-pub fn record(repo: &Path, commit: &str, outcomes: &[RunOutcome]) -> Result<(), git_store::Error> {
- record_with(&git_store::Store::open(repo)?, commit, outcomes)
-}
-
-/// Advance the latest run recorded for `commit` to `outcomes`, in place,
-/// through an already-open `store`. Unlike [`record_with`], which appends a
-/// new run, this replaces the run ref's tip commit (re-parented on the prior
-/// run) so a single run's status can progress — `queued` → `running` →
-/// results — without appending a commit per transition.
+/// Advance the latest run recorded for `commit` to `outcomes`, in place, in
+/// `repo`. Unlike [`record`], which appends a new run, this replaces the run
+/// ref's tip commit (re-parented on the prior run) so a single run's status can
+/// progress — `queued` → `running` → results — without appending a commit per
+/// transition.
///
/// When no run has been recorded yet the update starts one, so a worker that
/// advances a run is self-healing even if the `queued` record never landed.
-pub fn update_run_with(
- store: &git_store::Store,
- commit: &str,
- outcomes: &[RunOutcome],
-) -> Result<(), git_store::Error> {
- store.amend(
- &format!("{RUNS_NS}/{commit}"),
- &run_doc(outcomes),
- "Record check run",
- )
-}
-
-/// Advance the latest run recorded for `commit` to `outcomes`. See
-/// [`update_run_with`].
pub fn update_run(
repo: &Path,
commit: &str,
outcomes: &[RunOutcome],
) -> Result<(), git_store::Error> {
- update_run_with(&git_store::Store::open(repo)?, commit, outcomes)
+ git_store::Store::open(repo)?.amend(
+ &format!("{RUNS_NS}/{commit}"),
+ &run_doc(outcomes),
+ "Record check run",
+ )
}
-/// List the recorded runs per commit from an already-open `store`, newest
-/// commit first. Each commit's runs are the ref's commit chain, newest first,
-/// with the run time taken from each commit's date.
-pub fn runs_with(store: &git_store::Store) -> Result<Vec<CommitRuns>, git_store::Error> {
+/// List the recorded runs per commit in `repo`, newest commit first. Each
+/// commit's runs are the ref's commit chain, newest first, with the run time
+/// taken from each commit's date.
+pub fn runs(repo: &Path) -> Result<Vec<CommitRuns>, git_store::Error> {
+ let store = git_store::Store::open(repo)?;
let prefix = format!("{RUNS_NS}/");
let mut commits = Vec::new();
for refname in store.list(&prefix)? {
@@ -245,11 +216,6 @@
Ok(commits)
}
-/// List the recorded runs per commit in `repo`. See [`runs_with`].
-pub fn runs(repo: &Path) -> Result<Vec<CommitRuns>, git_store::Error> {
- runs_with(&git_store::Store::open(repo)?)
-}
-
/// Build a [`RunResults`] from a run's `outcomes`.
fn run_doc(outcomes: &[RunOutcome]) -> RunResults {
RunResults {
crates/git-ents/src/comments.rs
@@ -42,33 +42,24 @@
git_store::content_hash(content)
}
-/// Load the comment `comment_id` on `issue_id` from an already-open `store`.
-pub fn load_with(
- store: &git_store::Store,
- issue_id: &str,
- comment_id: &str,
-) -> Result<Option<Comment>, git_store::Error> {
- store.load_item(&issue_comments_ns(issue_id), comment_id)
-}
-
-/// Load the comment `comment_id` on `issue_id` in `repo`. See [`load_with`].
+/// Load the comment `comment_id` on `issue_id` in `repo`.
pub fn load(
repo: &Path,
issue_id: &str,
comment_id: &str,
) -> Result<Option<Comment>, git_store::Error> {
- load_with(&git_store::Store::open(repo)?, issue_id, comment_id)
+ git_store::Store::open(repo)?.load_item(&issue_comments_ns(issue_id), comment_id)
}
-/// Write `comment` at `refs/meta/comments/<issue_id>/<comment_id>` through an
-/// already-open `store`, where `comment_id` is [`new_id`] of `comment`.
-pub fn store_with(
- store: &git_store::Store,
+/// Write `comment` at `refs/meta/comments/<issue_id>/<comment_id>` in `repo`,
+/// where `comment_id` is [`new_id`] of `comment`.
+pub fn store(
+ repo: &Path,
issue_id: &str,
comment_id: &str,
comment: &Comment,
) -> Result<(), git_store::Error> {
- store.store_item(
+ git_store::Store::open(repo)?.store_item(
&issue_comments_ns(issue_id),
comment_id,
comment,
@@ -76,33 +67,10 @@
)
}
-/// Write `comment`. See [`store_with`].
-pub fn store(
- repo: &Path,
- issue_id: &str,
- comment_id: &str,
- comment: &Comment,
-) -> Result<(), git_store::Error> {
- store_with(
- &git_store::Store::open(repo)?,
- issue_id,
- comment_id,
- comment,
- )
-}
-
-/// List every comment on `issue_id` from an already-open `store`, as
-/// `(comment_id, comment)` pairs, newest first.
-pub fn list_with(
- store: &git_store::Store,
- issue_id: &str,
-) -> Result<Vec<(String, Comment)>, git_store::Error> {
- store.list_items(&issue_comments_ns(issue_id))
-}
-
-/// List every comment on `issue_id` in `repo`. See [`list_with`].
+/// List every comment on `issue_id` in `repo`, as `(comment_id, comment)`
+/// pairs, newest first.
pub fn list(repo: &Path, issue_id: &str) -> Result<Vec<(String, Comment)>, git_store::Error> {
- list_with(&git_store::Store::open(repo)?, issue_id)
+ git_store::Store::open(repo)?.list_items(&issue_comments_ns(issue_id))
}
#[cfg(test)]
crates/git-ents/src/config.rs
@@ -43,60 +43,34 @@
load_with(&git_store::Store::open(repo)?)
}
-/// Write `config` to [`CONFIG_REF`] through an already-open `store`,
-/// replacing any existing value as a new commit.
-pub fn store_with(store: &git_store::Store, config: &Config) -> Result<(), git_store::Error> {
- store_to_ref_with(store, CONFIG_REF, config)
-}
-
-/// Write `config` to [`CONFIG_REF`]. See [`store_with`].
+/// Write `config` to [`CONFIG_REF`] in `repo`, replacing any existing value as
+/// a new commit.
pub fn store(repo: &Path, config: &Config) -> Result<(), git_store::Error> {
- store_with(&git_store::Store::open(repo)?, config)
+ store_to_ref(repo, CONFIG_REF, config)
}
-/// Build the configuration commit on `refname` — chaining on that ref's own
-/// tip — without touching [`CONFIG_REF`], through an already-open `store`.
+/// Build the configuration commit on `refname` in `repo` — chaining on that
+/// ref's own tip — without touching [`CONFIG_REF`].
///
/// The web write path stages an edit on a throwaway ref pointed at the current
/// config tip, then lands it onto [`CONFIG_REF`] through a signed push, so the
/// `pre-receive` gate judges the change rather than this writing the live ref
/// directly.
-pub fn store_to_ref_with(
- store: &git_store::Store,
- refname: &str,
- config: &Config,
-) -> Result<(), git_store::Error> {
- store.store(refname, config, "Update configuration")
-}
-
-/// Build the configuration commit on `refname` in `repo`. See
-/// [`store_to_ref_with`].
pub fn store_to_ref(repo: &Path, refname: &str, config: &Config) -> Result<(), git_store::Error> {
- store_to_ref_with(&git_store::Store::open(repo)?, refname, config)
+ git_store::Store::open(repo)?.store(refname, config, "Update configuration")
}
-/// Like [`store_to_ref_with`], but recording `author` (a `(name, email)` pair)
-/// as the commit's author while the committer stays the git-ents system
-/// identity. The web write path uses this so an edit landed by the server
-/// still names the human who made it.
-pub fn store_to_ref_authored_with(
- store: &git_store::Store,
- refname: &str,
- config: &Config,
- author: (&str, &str),
-) -> Result<(), git_store::Error> {
- store.store_authored(refname, config, "Update configuration", author)
-}
-
-/// Like [`store_to_ref`], recording `author` as the commit's author. See
-/// [`store_to_ref_authored_with`].
+/// Like [`store_to_ref`], but recording `author` (a `(name, email)` pair) as
+/// the commit's author while the committer stays the git-ents system identity.
+/// The web write path uses this so an edit landed by the server still names the
+/// human who made it.
pub fn store_to_ref_authored(
repo: &Path,
refname: &str,
config: &Config,
author: (&str, &str),
) -> Result<(), git_store::Error> {
- store_to_ref_authored_with(&git_store::Store::open(repo)?, refname, config, author)
+ git_store::Store::open(repo)?.store_authored(refname, config, "Update configuration", author)
}
#[cfg(test)]
crates/git-ents/src/issues.rs
@@ -82,42 +82,21 @@
}
}
-/// Load the issue named `id` from an already-open `store`.
-pub fn load_with(store: &git_store::Store, id: &str) -> Result<Option<Issue>, git_store::Error> {
- store.load_item(ISSUES_NS, id)
-}
-
/// Load the issue recorded at `refs/meta/issues/<id>` in `repo`, or `None` when
/// no such issue exists.
pub fn load(repo: &Path, id: &str) -> Result<Option<Issue>, git_store::Error> {
- load_with(&git_store::Store::open(repo)?, id)
+ git_store::Store::open(repo)?.load_item(ISSUES_NS, id)
}
-/// Write `issue` to `refs/meta/issues/<id>` through an already-open `store`,
-/// replacing any existing value as a new commit so the ref's commit chain is
-/// the issue's edit history.
-pub fn store_with(
- store: &git_store::Store,
- id: &str,
- issue: &Issue,
-) -> Result<(), git_store::Error> {
- store.store_item(ISSUES_NS, id, issue, "Update issue")
-}
-
-/// Write `issue` to `refs/meta/issues/<id>`. See [`store_with`].
+/// Write `issue` to `refs/meta/issues/<id>` in `repo`, replacing any existing
+/// value as a new commit so the ref's commit chain is the issue's edit history.
pub fn store(repo: &Path, id: &str, issue: &Issue) -> Result<(), git_store::Error> {
- store_with(&git_store::Store::open(repo)?, id, issue)
-}
-
-/// List every issue from an already-open `store` as `(id, issue)` pairs,
-/// newest issue ref first.
-pub fn list_with(store: &git_store::Store) -> Result<Vec<(String, Issue)>, git_store::Error> {
- store.list_items(ISSUES_NS)
+ git_store::Store::open(repo)?.store_item(ISSUES_NS, id, issue, "Update issue")
}
/// List every issue in `repo` as `(id, issue)` pairs, newest issue ref first.
pub fn list(repo: &Path) -> Result<Vec<(String, Issue)>, git_store::Error> {
- list_with(&git_store::Store::open(repo)?)
+ git_store::Store::open(repo)?.list_items(ISSUES_NS)
}
/// The number of open issues in `repo`.
@@ -128,7 +107,7 @@
.count())
}
-/// Why [`promote_with`] could not promote an issue.
+/// Why [`promote`] could not promote an issue.
#[derive(Debug, thiserror::Error)]
pub enum PromoteError {
/// The underlying store failed to read or write a ref.
@@ -139,7 +118,7 @@
NotFound(String),
}
-/// How many times [`promote_with`] retries the counter CAS before giving up.
+/// How many times [`promote`] retries the counter CAS before giving up.
/// Bounds retry under sustained contention; ordinary races resolve in one or
/// two rounds.
const MAX_PROMOTE_RETRIES: usize = 5;
@@ -156,7 +135,8 @@
/// callers believe they claimed it. A CAS conflict here is retried by
/// re-reading the counter, so the number handed back is always the one
/// actually reserved for this call.
-pub fn promote_with(store: &git_store::Store, id: &str) -> Result<String, PromoteError> {
+pub fn promote(repo: &Path, id: &str) -> Result<String, PromoteError> {
+ let store = git_store::Store::open(repo)?;
let mut number = None;
for _ in 0..=MAX_PROMOTE_RETRIES {
let current = store
@@ -176,17 +156,14 @@
}
let number = number.ok_or(git_store::Error::Conflict)?.to_string();
- let mut issue = load_with(store, id)?.ok_or_else(|| PromoteError::NotFound(id.to_owned()))?;
+ let mut issue = store
+ .load_item::<Issue>(ISSUES_NS, id)?
+ .ok_or_else(|| PromoteError::NotFound(id.to_owned()))?;
issue.id = Some(number.clone());
- store_with(store, id, &issue)?;
+ store.store_item(ISSUES_NS, id, &issue, "Update issue")?;
Ok(number)
}
-/// Promote the issue at `id` in `repo`. See [`promote_with`].
-pub fn promote(repo: &Path, id: &str) -> Result<String, PromoteError> {
- promote_with(&git_store::Store::open(repo)?, id)
-}
-
#[cfg(test)]
mod tests {
#![allow(
crates/git-ents/src/members.rs
@@ -231,8 +231,8 @@
load_all_with(&git_store::Store::open(repo)?)
}
-/// Load every member recorded under [`MEMBER_NS`] from an already-open
-/// `store`, keyed by principal.
+/// Load every member recorded under [`MEMBER_NS`] in `repo`, keyed by
+/// principal.
///
/// Prepares the batch path for lookups keyed by principal directly (there is
/// exactly one member per principal, unlike a signing key, which a member may
@@ -243,27 +243,14 @@
/// yet wired to any caller: the web layer's public-key lookup needs a
/// different index (key → member), an O(m×k) linear scan that stays fine at
/// current scale (see its own doc comment).
-pub fn load_all_indexed_with(
- store: &git_store::Store,
-) -> Result<iddqd::IdOrdMap<Member>, git_store::Error> {
- Ok(load_all_with(store)?.into_iter().collect())
-}
-
-/// Load every member recorded under [`MEMBER_NS`] in `repo`, keyed by
-/// principal. See [`load_all_indexed_with`].
pub fn load_all_indexed(repo: &Path) -> Result<iddqd::IdOrdMap<Member>, git_store::Error> {
- load_all_indexed_with(&git_store::Store::open(repo)?)
+ Ok(load_all(repo)?.into_iter().collect())
}
-/// Write `member` to its `refs/meta/member/<principal>` ref, replacing any
-/// prior value, as a new commit, through an already-open `store`.
-pub fn store_with(store: &git_store::Store, member: &Member) -> Result<(), git_store::Error> {
- store.store_keyed(MEMBER_NS, member, "Update member")
-}
-
-/// Write `member` to its `refs/meta/member/<principal>` ref. See [`store_with`].
+/// Write `member` to its `refs/meta/member/<principal>` ref in `repo`,
+/// replacing any prior value, as a new commit.
pub fn store(repo: &Path, member: &Member) -> Result<(), git_store::Error> {
- store_with(&git_store::Store::open(repo)?, member)
+ git_store::Store::open(repo)?.store_keyed(MEMBER_NS, member, "Update member")
}
/// Drop every `revoked` fingerprint from `members`, returning the trust set the
crates/git-ents/src/reviews.rs
@@ -49,33 +49,20 @@
format!("{REVIEWS_NS}/{target_id}")
}
-/// Load `principal`'s review of `target_id` from an already-open `store`.
-pub fn load_with(
- store: &git_store::Store,
- target_id: &str,
- principal: &str,
-) -> Result<Option<Review>, git_store::Error> {
- store.load_item(&target_reviews_ns(target_id), principal)
-}
-
-/// Load `principal`'s review of `target_id` in `repo`. See [`load_with`].
+/// Load `principal`'s review of `target_id` in `repo`.
pub fn load(
repo: &Path,
target_id: &str,
principal: &str,
) -> Result<Option<Review>, git_store::Error> {
- load_with(&git_store::Store::open(repo)?, target_id, principal)
+ git_store::Store::open(repo)?.load_item(&target_reviews_ns(target_id), principal)
}
-/// Write `review` at `refs/meta/reviews/<target_id>/<review.principal>`
-/// through an already-open `store`, replacing that reviewer's prior verdict
-/// on `target_id` as a new commit.
-pub fn store_with(
- store: &git_store::Store,
- target_id: &str,
- review: &Review,
-) -> Result<(), git_store::Error> {
- store.store_item(
+/// Write `review` at `refs/meta/reviews/<target_id>/<review.principal>` in
+/// `repo`, replacing that reviewer's prior verdict on `target_id` as a new
+/// commit.
+pub fn store(repo: &Path, target_id: &str, review: &Review) -> Result<(), git_store::Error> {
+ git_store::Store::open(repo)?.store_item(
&target_reviews_ns(target_id),
&review.principal,
review,
@@ -83,23 +70,10 @@
)
}
-/// Write `review`. See [`store_with`].
-pub fn store(repo: &Path, target_id: &str, review: &Review) -> Result<(), git_store::Error> {
- store_with(&git_store::Store::open(repo)?, target_id, review)
-}
-
-/// List every review of `target_id` from an already-open `store`, as
-/// `(principal, review)` pairs, newest first.
-pub fn list_with(
- store: &git_store::Store,
- target_id: &str,
-) -> Result<Vec<(String, Review)>, git_store::Error> {
- store.list_items(&target_reviews_ns(target_id))
-}
-
-/// List every review of `target_id` in `repo`. See [`list_with`].
+/// List every review of `target_id` in `repo`, as `(principal, review)` pairs,
+/// newest first.
pub fn list(repo: &Path, target_id: &str) -> Result<Vec<(String, Review)>, git_store::Error> {
- list_with(&git_store::Store::open(repo)?, target_id)
+ git_store::Store::open(repo)?.list_items(&target_reviews_ns(target_id))
}
/// Whether `target_id` is ready to merge: aggregated at read time from its
crates/git-ents/src/revocations.rs
@@ -56,10 +56,10 @@
pub reason: String,
}
-/// Load the revocations recorded at [`REVOKED_REF`] from an already-open
-/// `store`. An absent ref yields an empty list — nothing is revoked.
-pub fn load_with(store: &git_store::Store) -> Result<Vec<Revocation>, git_store::Error> {
- Ok(store
+/// Load the revocations recorded at [`REVOKED_REF`] in `repo`. An absent ref
+/// yields an empty list — nothing is revoked.
+pub fn load(repo: &Path) -> Result<Vec<Revocation>, git_store::Error> {
+ Ok(git_store::Store::open(repo)?
.load::<Revocations>(REVOKED_REF)?
.map(|doc| {
doc.revoked
@@ -73,18 +73,9 @@
.unwrap_or_default())
}
-/// Load the revocations recorded at [`REVOKED_REF`] in `repo`. See
-/// [`load_with`].
-pub fn load(repo: &Path) -> Result<Vec<Revocation>, git_store::Error> {
- load_with(&git_store::Store::open(repo)?)
-}
-
-/// Write `revocations` to [`REVOKED_REF`] through an already-open `store`,
-/// replacing any existing list as a new commit.
-pub fn store_with(
- store: &git_store::Store,
- revocations: &[Revocation],
-) -> Result<(), git_store::Error> {
+/// Write `revocations` to [`REVOKED_REF`] in `repo`, replacing any existing
+/// list as a new commit.
+pub fn store(repo: &Path, revocations: &[Revocation]) -> Result<(), git_store::Error> {
let doc = Revocations {
revoked: revocations
.iter()
@@ -99,21 +90,16 @@
})
.collect(),
};
- store.store(REVOKED_REF, &doc, "Update revocations")
-}
-
-/// Write `revocations` to [`REVOKED_REF`]. See [`store_with`].
-pub fn store(repo: &Path, revocations: &[Revocation]) -> Result<(), git_store::Error> {
- store_with(&git_store::Store::open(repo)?, revocations)
+ git_store::Store::open(repo)?.store(REVOKED_REF, &doc, "Update revocations")
}
/// The set of revoked fingerprints recorded at [`REVOKED_REF`] from an
/// already-open `store`, for the verifier to subtract from the trust set.
pub fn fingerprints_with(store: &git_store::Store) -> Result<BTreeSet<String>, git_store::Error> {
- Ok(load_with(store)?
- .into_iter()
- .map(|revocation| revocation.fingerprint)
- .collect())
+ Ok(store
+ .load::<Revocations>(REVOKED_REF)?
+ .map(|doc| doc.revoked.into_keys().collect())
+ .unwrap_or_default())
}
/// The set of revoked fingerprints recorded at [`REVOKED_REF`] in `repo`. See