radicle: Allow creating bare clones
This commit is contained in:
parent
e528c40a07
commit
766e281d39
|
|
@ -98,7 +98,7 @@ fn execute(options: Options, profile: &Profile) -> anyhow::Result<PathBuf> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut spinner = term::spinner("Performing checkout...");
|
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,
|
Ok(repo) => repo,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
spinner.failed();
|
spinner.failed();
|
||||||
|
|
|
||||||
|
|
@ -274,7 +274,7 @@ impl Checkout {
|
||||||
"Creating checkout in ./{}..",
|
"Creating checkout in ./{}..",
|
||||||
term::format::tertiary(destination.display())
|
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) => {
|
Err(err) => {
|
||||||
spinner.message(format!(
|
spinner.message(format!(
|
||||||
"Failed to checkout in ./{}",
|
"Failed to checkout in ./{}",
|
||||||
|
|
|
||||||
|
|
@ -562,6 +562,7 @@ fn test_clone() {
|
||||||
alice.signer.public_key(),
|
alice.signer.public_key(),
|
||||||
tmp.path().join("clone"),
|
tmp.path().join("clone"),
|
||||||
&alice.storage,
|
&alice.storage,
|
||||||
|
false,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -251,6 +251,7 @@ pub fn checkout<P: AsRef<Path>, S: storage::ReadStorage>(
|
||||||
remote: &RemoteId,
|
remote: &RemoteId,
|
||||||
path: P,
|
path: P,
|
||||||
storage: &S,
|
storage: &S,
|
||||||
|
bare: bool,
|
||||||
) -> Result<git2::Repository, CheckoutError> {
|
) -> Result<git2::Repository, CheckoutError> {
|
||||||
// TODO: Decide on whether we can use `clone_local`
|
// TODO: Decide on whether we can use `clone_local`
|
||||||
// TODO: Look into sharing object databases.
|
// 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();
|
let mut opts = git2::RepositoryInitOptions::new();
|
||||||
opts.no_reinit(true)
|
opts.no_reinit(true)
|
||||||
.external_template(false)
|
.external_template(false)
|
||||||
.description(project.description());
|
.description(project.description())
|
||||||
|
.bare(bare);
|
||||||
|
|
||||||
let repo = git2::Repository::init_opts(path.as_ref(), &opts)?;
|
let repo = git2::Repository::init_opts(path.as_ref(), &opts)?;
|
||||||
let url = git::Url::from(proj);
|
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");
|
.expect("checkout: default branch name is valid UTF-8");
|
||||||
|
|
||||||
repo.set_head(branch_ref)?;
|
repo.set_head(branch_ref)?;
|
||||||
repo.checkout_head(None)?;
|
if !bare {
|
||||||
|
repo.checkout_head(None)?;
|
||||||
|
}
|
||||||
|
|
||||||
// Setup remote tracking for default branch.
|
// Setup remote tracking for default branch.
|
||||||
git::set_upstream(&repo, &*REMOTE_NAME, project.default_branch(), branch_ref)?;
|
git::set_upstream(&repo, &*REMOTE_NAME, project.default_branch(), branch_ref)?;
|
||||||
|
|
@ -549,7 +553,7 @@ mod tests {
|
||||||
|
|
||||||
// Bob forks it and creates a checkout.
|
// Bob forks it and creates a checkout.
|
||||||
fork(id, &bob, &storage).unwrap();
|
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();
|
let bob_remote = storage.repository(id).unwrap().remote(bob_id).unwrap();
|
||||||
|
|
||||||
|
|
@ -584,7 +588,7 @@ mod tests {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
git::set_upstream(&original, "rad", "master", "refs/heads/master").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!(
|
assert_eq!(
|
||||||
copy.head().unwrap().target(),
|
copy.head().unwrap().target(),
|
||||||
|
|
|
||||||
|
|
@ -570,6 +570,7 @@ mod tests {
|
||||||
bob.public_key(),
|
bob.public_key(),
|
||||||
tmp.path().join("working"),
|
tmp.path().join("working"),
|
||||||
&storage,
|
&storage,
|
||||||
|
false,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue