Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
radicle: Allow creating bare clones
Lorenz Leutgeb committed 7 months ago
commit 766e281d3928fe35da422a685657713cad0ea339
parent e528c40a07f1a7d1ecfd4808b5a7ef8e5fb8bb0c
5 files changed +12 -6
modified crates/radicle-cli/src/commands/checkout.rs
@@ -98,7 +98,7 @@ fn execute(options: Options, profile: &Profile) -> anyhow::Result<PathBuf> {
    }

    let mut spinner = term::spinner("Performing checkout...");
-
    let repo = match radicle::rad::checkout(options.id, &remote, path.clone(), &storage) {
+
    let repo = match radicle::rad::checkout(options.id, &remote, path.clone(), &storage, false) {
        Ok(repo) => repo,
        Err(err) => {
            spinner.failed();
modified crates/radicle-cli/src/commands/clone.rs
@@ -274,7 +274,7 @@ impl Checkout {
            "Creating checkout in ./{}..",
            term::format::tertiary(destination.display())
        ));
-
        match rad::checkout(self.id, &self.remote, self.path, storage) {
+
        match rad::checkout(self.id, &self.remote, self.path, storage, false) {
            Err(err) => {
                spinner.message(format!(
                    "Failed to checkout in ./{}",
modified crates/radicle-node/src/tests/e2e.rs
@@ -562,6 +562,7 @@ fn test_clone() {
        alice.signer.public_key(),
        tmp.path().join("clone"),
        &alice.storage,
+
        false,
    )
    .unwrap();

modified crates/radicle/src/rad.rs
@@ -251,6 +251,7 @@ pub fn checkout<P: AsRef<Path>, S: storage::ReadStorage>(
    remote: &RemoteId,
    path: P,
    storage: &S,
+
    bare: bool,
) -> Result<git2::Repository, CheckoutError> {
    // TODO: Decide on whether we can use `clone_local`
    // TODO: Look into sharing object databases.
@@ -260,7 +261,8 @@ pub fn checkout<P: AsRef<Path>, S: storage::ReadStorage>(
    let mut opts = git2::RepositoryInitOptions::new();
    opts.no_reinit(true)
        .external_template(false)
-
        .description(project.description());
+
        .description(project.description())
+
        .bare(bare);

    let repo = git2::Repository::init_opts(path.as_ref(), &opts)?;
    let url = git::Url::from(proj);
@@ -318,7 +320,9 @@ pub fn checkout<P: AsRef<Path>, S: storage::ReadStorage>(
            .expect("checkout: default branch name is valid UTF-8");

        repo.set_head(branch_ref)?;
-
        repo.checkout_head(None)?;
+
        if !bare {
+
            repo.checkout_head(None)?;
+
        }

        // Setup remote tracking for default branch.
        git::set_upstream(&repo, &*REMOTE_NAME, project.default_branch(), branch_ref)?;
@@ -549,7 +553,7 @@ mod tests {

        // Bob forks it and creates a checkout.
        fork(id, &bob, &storage).unwrap();
-
        checkout(id, bob_id, tempdir.path().join("copy"), &storage).unwrap();
+
        checkout(id, bob_id, tempdir.path().join("copy"), &storage, false).unwrap();

        let bob_remote = storage.repository(id).unwrap().remote(bob_id).unwrap();

@@ -584,7 +588,7 @@ mod tests {
        .unwrap();
        git::set_upstream(&original, "rad", "master", "refs/heads/master").unwrap();

-
        let copy = checkout(id, remote_id, tempdir.path().join("copy"), &storage).unwrap();
+
        let copy = checkout(id, remote_id, tempdir.path().join("copy"), &storage, false).unwrap();

        assert_eq!(
            copy.head().unwrap().target(),
modified crates/radicle/src/storage/refs.rs
@@ -570,6 +570,7 @@ mod tests {
                bob.public_key(),
                tmp.path().join("working"),
                &storage,
+
                false,
            )
            .unwrap();