Add method to get owned commit of branch

This commit is contained in:
2022-06-23 19:18:07 +02:00
parent e78dcf471a
commit ee44fa40fd

View File

@@ -1435,7 +1435,7 @@ impl<'a> Branch<'a> {
}
}
impl Branch<'_> {
impl<'a> Branch<'a> {
pub fn commit(&self) -> Result<Commit, String> {
Ok(Commit(
self.0
@@ -1445,6 +1445,15 @@ impl Branch<'_> {
))
}
pub fn commit_owned(self) -> Result<Commit<'a>, String> {
Ok(Commit(
self.0
.into_reference()
.peel_to_commit()
.map_err(convert_libgit2_error)?,
))
}
pub fn set_upstream(&mut self, remote_name: &str, branch_name: &str) -> Result<(), String> {
self.0
.set_upstream(Some(&format!("{}/{}", remote_name, branch_name)))