From ee44fa40fd4da07946c47fb9d6b4c9db059b521d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20K=C3=B6rber?= Date: Thu, 23 Jun 2022 19:18:07 +0200 Subject: [PATCH] Add method to get owned commit of branch --- src/repo.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/repo.rs b/src/repo.rs index f6b92d5..206b1fe 100644 --- a/src/repo.rs +++ b/src/repo.rs @@ -1435,7 +1435,7 @@ impl<'a> Branch<'a> { } } -impl Branch<'_> { +impl<'a> Branch<'a> { pub fn commit(&self) -> Result { Ok(Commit( self.0 @@ -1445,6 +1445,15 @@ impl Branch<'_> { )) } + pub fn commit_owned(self) -> Result, 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)))