upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/git.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2024-02-22 14:56:13 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2024-02-22 14:56:33 +0000
commit350c70bf1569815534d028eafa810b34d04f1f3d (patch)
tree17ba54ac197f6ba1d2900f4cfb86a571da29a68c /src/git.rs
parente11ddc792864f9f0f84887701d919b6c8dc32fe0 (diff)
fix(pull): local rebase detected as ammendments
also updated copy and code comments
Diffstat (limited to 'src/git.rs')
-rw-r--r--src/git.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/git.rs b/src/git.rs
index 6edca0f..41d68c7 100644
--- a/src/git.rs
+++ b/src/git.rs
@@ -68,6 +68,7 @@ pub trait RepoActions {
68 patch_and_ancestors: Vec<nostr::Event>, 68 patch_and_ancestors: Vec<nostr::Event>,
69 ) -> Result<Vec<nostr::Event>>; 69 ) -> Result<Vec<nostr::Event>>;
70 fn parse_starting_commits(&self, starting_commits: &str) -> Result<Vec<Sha1Hash>>; 70 fn parse_starting_commits(&self, starting_commits: &str) -> Result<Vec<Sha1Hash>>;
71 fn ancestor_of(&self, decendant: &Sha1Hash, ancestor: &Sha1Hash) -> Result<bool>;
71} 72}
72 73
73impl RepoActions for Repo { 74impl RepoActions for Repo {
@@ -461,6 +462,18 @@ impl RepoActions for Repo {
461 bail!("specified value not in a supported format") 462 bail!("specified value not in a supported format")
462 } 463 }
463 } 464 }
465
466 fn ancestor_of(&self, decendant: &Sha1Hash, ancestor: &Sha1Hash) -> Result<bool> {
467 if let Ok(res) = self
468 .git_repo
469 .graph_descendant_of(sha1_to_oid(decendant)?, sha1_to_oid(ancestor)?)
470 .context("could not run graph_descendant_of in gitlib2")
471 {
472 Ok(res)
473 } else {
474 Ok(false)
475 }
476 }
464} 477}
465 478
466fn oid_to_u8_20_bytes(oid: &Oid) -> [u8; 20] { 479fn oid_to_u8_20_bytes(oid: &Oid) -> [u8; 20] {