Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
cli/test: Canonical References
✗ CI failure Lorenz Leutgeb committed 22 days ago
commit 259b4d37257e5b886696b3b976544529cfceccf6
parent 1bf20f8b05bfdef317b3ae2187812e1feff59d2c
1 failed (1 total) View logs
3 files changed +261 -1
added crates/radicle-cli/examples/git/git-push-canonical-branch.md
@@ -0,0 +1,90 @@
+
``` ~alice
+
$ rad id update --title "Add canonical branch for releases" --payload xyz.radicle.crefs rules '{ "refs/heads/releases/*": { "threshold": 1, "allow": [ "did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk" ] }, "refs/tags/*": { "threshold": 1, "allow": "delegates" }, "refs/tags/qa/*": { "threshold": 1, "allow": "delegates" }}'
+
✓ Identity revision [..] created
+
╭────────────────────────────────────────────────────────────────────────╮
+
│ Title    Add canonical branch for releases                             │
+
│ Revision 37a1aad231100cd206c49aed79e405ea2da9204b                      │
+
│ Blob     bbefd77cfeb456e500ad868c3b4effe1f7f818e2                      │
+
│ Author   did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi      │
+
│ State    active                                                        │
+
│ Quorum   no                                                            │
+
├────────────────────────────────────────────────────────────────────────┤
+
│ ✓ did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi alice (you) │
+
│ ? did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk bob         │
+
╰────────────────────────────────────────────────────────────────────────╯
+

+
@@ -1,26 +1,32 @@
+
 {
+
   "payload": {
+
     "xyz.radicle.crefs": {
+
       "rules": {
+
+        "refs/heads/releases/*": {
+
+          "allow": [
+
+            "did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk"
+
+          ],
+
+          "threshold": 1
+
+        },
+
         "refs/tags/*": {
+
           "allow": "delegates",
+
-          "threshold": 2
+
+          "threshold": 1
+
         },
+
         "refs/tags/qa/*": {
+
           "allow": "delegates",
+
           "threshold": 1
+
         }
+
       }
+
     },
+
     "xyz.radicle.project": {
+
       "defaultBranch": "master",
+
       "description": "Radicle Heartwood Protocol & Stack",
+
       "name": "heartwood"
+
     }
+
   },
+
   "delegates": [
+
     "did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi",
+
     "did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk"
+
   ],
+
   "threshold": 1
+
 }
+
```
+

+
``` ~bob
+
$ cd heartwood
+
$ rad sync -f
+
Fetching rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji from the network, found 1 potential seed(s).
+
✓ Target met: 1 seed(s)
+
🌱 Fetched from z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
+
$ rad id accept 37a1aad231100cd206c49aed79e405ea2da9204b -q
+
```
+

+
Bob immediately pushes a branch that matches the rule, thus populating
+
modifying the canonical namespace.
+

+
``` ~bob
+
$ git checkout -b releases/2
+
$ git commit --allow-empty --message "Release notes for version 2"
+
[releases/2 afec366] Release notes for version 2
+
```
+

+
``` ~bob (stderr)
+
$ git push -u rad releases/2
+
✓ Canonical reference refs/heads/releases/2 updated to target commit afec366785ed3651cdc66975c0fec41866c9ce62
+
✓ Synced with 1 seed(s)
+
To rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk
+
 * [new branch]      releases/2 -> releases/2
+
```
+

+
``` ~alice 
+
$ rad sync -f
+
Fetching rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji from the network, found 1 potential seed(s).
+
✓ Target met: 1 seed(s)
+
🌱 Fetched from z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk
+
$ git ls-remote rad
+
f2de534b5e81d7c6e2dcaf58c3dd91573c0a0354	HEAD
+
f2de534b5e81d7c6e2dcaf58c3dd91573c0a0354	refs/heads/master
+
afec366785ed3651cdc66975c0fec41866c9ce62	refs/heads/releases/2
+
f2de534b5e81d7c6e2dcaf58c3dd91573c0a0354	refs/tags/qa/v2.1
+
ac51a0746a5e8311829bc481202909a1e3acc0c2	refs/tags/v1.0-hotfix
+
89f935f27a16f8ed97915ade4accab8fe48057aa	refs/tags/v2.0
+
```

\ No newline at end of file
added crates/radicle-cli/examples/git/git-push-canonical-symbolic-ref.md
@@ -0,0 +1,130 @@
+
Bob overhears that the new default name for the default branch is "main",
+
not "master" as it used to be.
+
To make tooling that expect "main" work, without the hassle of having to push
+
to such branch manually, he opts to create a symbolic reference.
+

+
``` ~bob
+
$ cd heartwood
+
$ rad id update --title "Add canonical symbolic ref" --payload xyz.radicle.crefs symbolic '{ "refs/heads/main": "refs/heads/master" }'
+
✓ Identity revision [..] created
+
╭────────────────────────────────────────────────────────────────────────╮
+
│ Title    Add canonical symbolic ref                                    │
+
│ Revision 62e2cb60c6df9ad9908b6697b5d126760a855484                      │
+
│ Blob     b20de7b184673eb0d9227be17640c923d8ef3f3e                      │
+
│ Author   did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk      │
+
│ State    active                                                        │
+
│ Quorum   no                                                            │
+
├────────────────────────────────────────────────────────────────────────┤
+
│ ✓ did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk bob   (you) │
+
│ ? did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi alice       │
+
╰────────────────────────────────────────────────────────────────────────╯
+

+
@@ -1,32 +1,35 @@
+
 {
+
   "payload": {
+
     "xyz.radicle.crefs": {
+
       "rules": {
+
         "refs/heads/releases/*": {
+
           "allow": [
+
             "did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk"
+
           ],
+
           "threshold": 1
+
         },
+
         "refs/tags/*": {
+
           "allow": "delegates",
+
           "threshold": 1
+
         },
+
         "refs/tags/qa/*": {
+
           "allow": "delegates",
+
           "threshold": 1
+
         }
+
+      },
+
+      "symbolic": {
+
+        "refs/heads/main": "refs/heads/master"
+
       }
+
     },
+
     "xyz.radicle.project": {
+
       "defaultBranch": "master",
+
       "description": "Radicle Heartwood Protocol & Stack",
+
       "name": "heartwood"
+
     }
+
   },
+
   "delegates": [
+
     "did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi",
+
     "did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk"
+
   ],
+
   "threshold": 1
+
 }
+
```
+

+
Alice is happy with the new revision and accepts it.
+

+
``` ~alice
+
$ rad sync -f
+
Fetching rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji from the network, found 1 potential seed(s).
+
✓ Target met: 1 seed(s)
+
🌱 Fetched from z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk
+
$ rad id accept 62e2cb60c6df9ad9908b6697b5d126760a855484 -q
+
```
+

+
As usual, alice works on "master".
+

+
``` ~alice
+
$ git commit --allow-empty --message "Whew, new feature!"
+
[master 4dc510d] Whew, new feature!
+
```
+

+
And updating the canonical reference for "master" also works as usual.
+

+
``` ~alice (stderr)
+
$ git push rad
+
✓ Canonical reference refs/heads/master updated to target commit 4dc510ddea5fd66499d1d2e996b8a97c8d57be54
+
✓ Synced with 1 seed(s)
+
To rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
+
   f2de534..4dc510d  master -> master
+
```
+

+
Then, Alice is curious about the new symbolic reference.
+
She inspects the remote and sees that indeed a new branch named "main" now exists.
+

+
``` ~alice 
+
$ git ls-remote rad
+
4dc510ddea5fd66499d1d2e996b8a97c8d57be54	HEAD
+
4dc510ddea5fd66499d1d2e996b8a97c8d57be54	refs/heads/main
+
4dc510ddea5fd66499d1d2e996b8a97c8d57be54	refs/heads/master
+
afec366785ed3651cdc66975c0fec41866c9ce62	refs/heads/releases/2
+
f2de534b5e81d7c6e2dcaf58c3dd91573c0a0354	refs/tags/qa/v2.1
+
ac51a0746a5e8311829bc481202909a1e3acc0c2	refs/tags/v1.0-hotfix
+
89f935f27a16f8ed97915ade4accab8fe48057aa	refs/tags/v2.0
+
```
+

+
Of course, she can also fetch it to her working copy as usual.
+

+
``` ~alice (stderr)
+
$ git fetch rad
+
From rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji
+
 * [new branch]      main       -> rad/main
+
 * [new branch]      releases/2 -> rad/releases/2
+
 * [new tag]         qa/v2.1    -> rad/tags/qa/v2.1
+
 * [new tag]         qa/v2.1    -> qa/v2.1
+
```
+

+
Bob fetches Alice's changes.
+

+
``` ~bob
+
$ rad sync -f
+
Fetching rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji from the network, found 1 potential seed(s).
+
✓ Target met: 1 seed(s)
+
🌱 Fetched from z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
+
```
+

+
And, sure enough, there is the new branch just as he wanted it.
+

+
``` ~bob (stderr)
+
$ git fetch rad
+
From rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji
+
 * [new branch]      main       -> rad/main
+
   f2de534..4dc510d  master     -> rad/master
+
```
+

+
Note that neither Alice nor Bob pushed directly to "main".

\ No newline at end of file
modified crates/radicle-cli/tests/commands/git.rs
@@ -301,8 +301,12 @@ fn git_push_canonical_lightweight_tags() {
    .unwrap();
}

+
/// This test exercises a large surface of the "Canonical References" feature:
+
///  - Annotated Tags
+
///  - Branches
+
///  - Symbolic References
#[test]
-
fn git_push_canonical_annotated_tags() {
+
fn git_push_canonical() {
    let mut environment = Environment::new();
    let alice = environment.node("alice");
    let bob = environment.node("bob");
@@ -341,4 +345,40 @@ fn git_push_canonical_annotated_tags() {
    )
    .run()
    .unwrap();
+

+
    formula(
+
        &environment.tempdir(),
+
        "examples/git/git-push-canonical-branch.md",
+
    )
+
    .unwrap()
+
    .home(
+
        "alice",
+
        environment.work(&alice),
+
        [("RAD_HOME", alice.home.path().display())],
+
    )
+
    .home(
+
        "bob",
+
        environment.work(&bob),
+
        [("RAD_HOME", bob.home.path().display())],
+
    )
+
    .run()
+
    .unwrap();
+

+
    formula(
+
        &environment.tempdir(),
+
        "examples/git/git-push-canonical-symbolic-ref.md",
+
    )
+
    .unwrap()
+
    .home(
+
        "alice",
+
        environment.work(&alice),
+
        [("RAD_HOME", alice.home.path().display())],
+
    )
+
    .home(
+
        "bob",
+
        environment.work(&bob),
+
        [("RAD_HOME", bob.home.path().display())],
+
    )
+
    .run()
+
    .unwrap();
}