Add method to get owned commit of branch
This commit is contained in:
11
src/repo.rs
11
src/repo.rs
@@ -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)))
|
||||
|
||||
Reference in New Issue
Block a user