Skip to content

Commit

Permalink
surf: Rename Repository::blob to blob_at and add new blob fn
Browse files Browse the repository at this point in the history
The current `Repository::blob` function takes a commit id and a path,
and thus should be renamed to `blob_at` which represents more the API of
`git2`.
And we could really need a fn `Repository::blob` which only takes a blob
oid.
  • Loading branch information
sebastinez committed Nov 22, 2023
1 parent f83c6d6 commit 82b402f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion radicle-surf/src/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,14 @@ impl Repository {
Ok(Tree::new(dir.id(), entries, last_commit))
}

/// Returns a [`Blob`] for an `oid`.
pub fn blob(&self, oid: Oid) -> Result<Blob<BlobRef<'a>>, Error> {
let git2_blob = self.find_blob(oid)?;
Ok(Blob::<BlobRef<'a>>::new(file.id(), git2_blob, last_commit))
}

/// Returns a [`Blob`] for `path` in `commit`.
pub fn blob<'a, C: ToCommit, P: AsRef<Path>>(
pub fn blob_at<'a, C: ToCommit, P: AsRef<Path>>(
&'a self,
commit: C,
path: &P,
Expand Down

0 comments on commit 82b402f

Please sign in to comment.