diff options
Diffstat (limited to 'src/git.rs')
| -rw-r--r-- | src/git.rs | 13 |
1 files changed, 13 insertions, 0 deletions
| @@ -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 | ||
| 73 | impl RepoActions for Repo { | 74 | impl 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 | ||
| 466 | fn oid_to_u8_20_bytes(oid: &Oid) -> [u8; 20] { | 479 | fn oid_to_u8_20_bytes(oid: &Oid) -> [u8; 20] { |