upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/lib/git/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/git/mod.rs')
-rw-r--r--src/lib/git/mod.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/lib/git/mod.rs b/src/lib/git/mod.rs
index b9711ae..516d9e2 100644
--- a/src/lib/git/mod.rs
+++ b/src/lib/git/mod.rs
@@ -91,6 +91,7 @@ pub trait RepoActions {
91 ) -> Result<Oid>; 91 ) -> Result<Oid>;
92 fn parse_starting_commits(&self, starting_commits: &str) -> Result<Vec<Sha1Hash>>; 92 fn parse_starting_commits(&self, starting_commits: &str) -> Result<Vec<Sha1Hash>>;
93 fn ancestor_of(&self, decendant: &Sha1Hash, ancestor: &Sha1Hash) -> Result<bool>; 93 fn ancestor_of(&self, decendant: &Sha1Hash, ancestor: &Sha1Hash) -> Result<bool>;
94 fn get_upstream_for_branch(&self, branch_name: &str) -> Result<Option<String>>;
94 fn get_git_config_item(&self, item: &str, global: Option<bool>) -> Result<Option<String>>; 95 fn get_git_config_item(&self, item: &str, global: Option<bool>) -> Result<Option<String>>;
95 fn save_git_config_item(&self, item: &str, value: &str, global: bool) -> Result<()>; 96 fn save_git_config_item(&self, item: &str, value: &str, global: bool) -> Result<()>;
96 fn remove_git_config_item(&self, item: &str, global: bool) -> Result<bool>; 97 fn remove_git_config_item(&self, item: &str, global: bool) -> Result<bool>;
@@ -734,6 +735,21 @@ impl RepoActions for Repo {
734 } 735 }
735 } 736 }
736 737
738 fn get_upstream_for_branch(&self, branch_name: &str) -> Result<Option<String>> {
739 let branch = self
740 .git_repo
741 .find_branch(branch_name, git2::BranchType::Local)
742 .context(format!("failed to find local branch {branch_name}"))?;
743 let upstream = branch.upstream();
744 match upstream {
745 Ok(upstream_branch) => {
746 let name = upstream_branch.name()?.map(|s| s.to_string());
747 Ok(name)
748 }
749 Err(_) => Ok(None),
750 }
751 }
752
737 /// setting global to None will suppliment local config with global items 753 /// setting global to None will suppliment local config with global items
738 /// not in local 754 /// not in local
739 fn get_git_config_item(&self, item: &str, global: Option<bool>) -> Result<Option<String>> { 755 fn get_git_config_item(&self, item: &str, global: Option<bool>) -> Result<Option<String>> {