Make use of `git2::Repository::refname_to_id`
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
This commit is contained in:
parent
94f7675c72
commit
111480cd6e
|
|
@ -125,10 +125,8 @@ pub fn fork_remote<G: Signer, S: storage::WriteStorage>(
|
||||||
let repository = storage.repository(proj)?;
|
let repository = storage.repository(proj)?;
|
||||||
|
|
||||||
let raw = repository.raw();
|
let raw = repository.raw();
|
||||||
let remote_head = raw
|
let remote_head =
|
||||||
.find_reference(&git::refs::storage::branch(remote, &project.default_branch))?
|
raw.refname_to_id(&git::refs::storage::branch(remote, &project.default_branch))?;
|
||||||
.target()
|
|
||||||
.ok_or(ForkError::InvalidReference)?;
|
|
||||||
raw.reference(
|
raw.reference(
|
||||||
&git::refs::storage::branch(me, &project.default_branch),
|
&git::refs::storage::branch(me, &project.default_branch),
|
||||||
remote_head,
|
remote_head,
|
||||||
|
|
@ -136,10 +134,7 @@ pub fn fork_remote<G: Signer, S: storage::WriteStorage>(
|
||||||
&format!("creating default branch for {me}"),
|
&format!("creating default branch for {me}"),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let remote_id = raw
|
let remote_id = raw.refname_to_id(&git::refs::storage::id(remote))?;
|
||||||
.find_reference(&git::refs::storage::id(remote))?
|
|
||||||
.target()
|
|
||||||
.ok_or(ForkError::InvalidReference)?;
|
|
||||||
raw.reference(
|
raw.reference(
|
||||||
&git::refs::storage::id(me),
|
&git::refs::storage::id(me),
|
||||||
remote_id,
|
remote_id,
|
||||||
|
|
|
||||||
|
|
@ -437,11 +437,8 @@ impl ReadRepository for Repository {
|
||||||
remote: &RemoteId,
|
remote: &RemoteId,
|
||||||
reference: &git::Qualified,
|
reference: &git::Qualified,
|
||||||
) -> Result<Oid, git::Error> {
|
) -> Result<Oid, git::Error> {
|
||||||
// TODO: Use native git2 function for this.
|
let name = reference.with_namespace(remote.into());
|
||||||
let oid = self
|
let oid = self.backend.refname_to_id(&name)?;
|
||||||
.reference(remote, reference)?
|
|
||||||
.target()
|
|
||||||
.ok_or(git::Error::NotFound(git::NotFound::NoRefTarget))?;
|
|
||||||
|
|
||||||
Ok(oid.into())
|
Ok(oid.into())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue