Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
cli: Suggest correct command for pushing
cloudhead committed 2 years ago
commit 59c101fc592101c81120d0be68ba26521cb51243
parent 50460842f48b461a53529814078e20efc9dfda32
3 files changed +62 -2
added radicle-cli/examples/rad-init-with-existing-remote.md
@@ -0,0 +1,42 @@
+
Let's try to `rad init` a repo which already has a remote tracking branch for `master`.
+

+
First we have to create a valid remote repository.
+

+
```
+
$ git init --bare remote
+
Initialized empty Git repository in [..]
+
```
+

+
Then we add it as a remote.
+

+
```
+
$ git remote add origin file://$PWD/remote
+
$ git push -u origin master:master
+
branch 'master' set up to track 'origin/master'.
+
$ git branch -vv
+
* master f2de534 [origin/master] Second commit
+
```
+

+
Then we initialize.
+

+
```
+
$ rad init --name heartwood --description "Heartwood Protocol & Stack" --no-confirm --public
+

+
Initializing public radicle 👾 project in .
+

+
✓ Project heartwood created.
+

+
Your project's Repository ID (RID) is rad:z2D6wQnKapY7dn5meBnbH2rUKNZbT.
+
You can show it any time by running `rad .` from this directory.
+

+
Your project will be announced to the network when you start your node.
+
You can start your node with `rad node start`.
+
To push changes, run `git push rad master`.
+
```
+

+
Finally we run the suggested command.
+

+
``` (stderr)
+
$ git push rad master
+
Everything up-to-date
+
```
modified radicle-cli/src/commands/init.rs
@@ -271,7 +271,7 @@ pub fn init(options: Options, profile: &profile::Profile) -> anyhow::Result<()>
        &repo,
        &name,
        &description,
-
        branch,
+
        branch.clone(),
        visibility,
        &signer,
        &profile.storage,
@@ -304,7 +304,7 @@ pub fn init(options: Options, profile: &profile::Profile) -> anyhow::Result<()>
                    radicle::git::refs::workdir::branch(proj.default_branch()),
                )?;
            } else {
-
                push_cmd = format!("git push {}", *radicle::rad::REMOTE_NAME);
+
                push_cmd = format!("git push {} {branch}", *radicle::rad::REMOTE_NAME);
            }

            if options.setup_signing {
modified radicle-cli/tests/commands.rs
@@ -147,6 +147,24 @@ fn rad_init() {
}

#[test]
+
fn rad_init_with_existing_remote() {
+
    let mut environment = Environment::new();
+
    let profile = environment.profile(config::profile("alice"));
+
    let working = tempfile::tempdir().unwrap();
+

+
    // Setup a test repository.
+
    fixtures::repository(working.path());
+

+
    test(
+
        "examples/rad-init-with-existing-remote.md",
+
        working.path(),
+
        Some(&profile.home),
+
        [],
+
    )
+
    .unwrap();
+
}
+

+
#[test]
fn rad_init_no_git() {
    let mut environment = Environment::new();
    let profile = environment.profile(config::profile("alice"));