mirror of
https://seed.radicle.dev/rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5.git
synced 2026-11-16 00:00:37 +08:00
node: Implement project checkout
Signed-off-by: Alexis Sellier <self@cloudhead.io>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
use std::collections::{BTreeMap, HashSet};
|
||||
use std::hash::Hash;
|
||||
use std::ops::RangeBounds;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use nonempty::NonEmpty;
|
||||
use quickcheck::Arbitrary;
|
||||
@@ -56,8 +57,14 @@ impl Arbitrary for Project {
|
||||
let doc = Doc::arbitrary(g);
|
||||
let id = doc.write(&mut buf).unwrap();
|
||||
let remotes = storage::Remotes::arbitrary(g);
|
||||
let path = PathBuf::arbitrary(g);
|
||||
|
||||
Self { id, doc, remotes }
|
||||
Self {
|
||||
id,
|
||||
doc,
|
||||
remotes,
|
||||
path,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -63,6 +63,18 @@ pub fn storage<P: AsRef<Path>>(path: P) -> Storage {
|
||||
storages.pop().unwrap()
|
||||
}
|
||||
|
||||
/// Creates a regular repository at the given path with a couple of commits.
|
||||
pub fn repository<P: AsRef<Path>>(path: P) -> git2::Repository {
|
||||
let repo = git2::Repository::init(path).unwrap();
|
||||
{
|
||||
let sig = git2::Signature::now("anonymous", "anonymous@radicle.xyz").unwrap();
|
||||
let head = git::initial_commit(&repo, &sig).unwrap();
|
||||
let head = git::commit(&repo, &head, "Second commit", "anonymous").unwrap();
|
||||
let _branch = repo.branch("master", &head, false).unwrap();
|
||||
}
|
||||
repo
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
Reference in New Issue
Block a user