From 81dbf21e0b48b0d2a964a897d72fbec7c5803399 Mon Sep 17 00:00:00 2001 From: Mx Kookie Date: Wed, 4 Nov 2020 03:41:27 +0100 Subject: [PATCH] octopus: implementing octopus merge parsing --- apps/servers/octopus/supergit/src/bin/test.rs | 21 +++++++------------ apps/servers/octopus/supergit/src/branch.rs | 8 ++++++- apps/servers/octopus/supergit/src/commit.rs | 7 +++++++ 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/apps/servers/octopus/supergit/src/bin/test.rs b/apps/servers/octopus/supergit/src/bin/test.rs index 6a370dd3716..25652ed0bd3 100644 --- a/apps/servers/octopus/supergit/src/bin/test.rs +++ b/apps/servers/octopus/supergit/src/bin/test.rs @@ -30,21 +30,14 @@ fn main() { Commit(c) => println!("{}: {}", c.id_str(), c.summary()), Merge(c, _b) => { println!("{}: {}", c.id_str(), c.summary()); - // tx.send(b.get_all()).unwrap(); + tx.send(_b.get_all()).unwrap(); + } + Octopus(c, branches) => { + println!("{}: {}", c.id_str(), c.summary()); + for _b in branches { + tx.send(_b.get_all()).unwrap(); + } } - _ => todo!(), }); - - break; } - - // let rr = RawRepository::open(path.as_str()).unwrap(); - // let branches = rr.parse_branches().unwrap(); - - // for branch in branches { - // if branch.name.as_str() != "main" && continue {} - // println!("Branch: {}", branch.name); - - // branch.enumerate(" ".into(), &rr.inner); - // } } diff --git a/apps/servers/octopus/supergit/src/branch.rs b/apps/servers/octopus/supergit/src/branch.rs index 57b47684c36..fe555d24292 100644 --- a/apps/servers/octopus/supergit/src/branch.rs +++ b/apps/servers/octopus/supergit/src/branch.rs @@ -121,7 +121,13 @@ impl BranchIter { let p2 = self.parents(&curr).1.unwrap(); BranchCommit::Merge(curr, Branch::without_name(&self.repo, p2.id)) } - _ => panic!("Octopus merges not yet implemented!"), + _ => BranchCommit::Octopus( + curr.clone(), + curr.parents() + .into_iter() + .map(|c| Branch::without_name(&self.repo, c.id)) + .collect(), + ), } } diff --git a/apps/servers/octopus/supergit/src/commit.rs b/apps/servers/octopus/supergit/src/commit.rs index dc8c18a0c98..41c827f64d8 100644 --- a/apps/servers/octopus/supergit/src/commit.rs +++ b/apps/servers/octopus/supergit/src/commit.rs @@ -51,6 +51,13 @@ impl Commit { .and_then(|c| Self::new(&self.repo, c.id().into())) } + pub fn parents(&self) -> Vec { + self.find() + .parents() + .map(|c| Self::new(&self.repo, c.id().into()).unwrap()) + .collect() + } + fn find(&self) -> git2::Commit { self.repo.find_commit(self.id.to_oid()).unwrap() }