Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
cli: `rad cob {show → log}`
Lorenz Leutgeb committed 1 year ago
commit 72dad241e2b990b826a4c5e9bd6fef09ca67bf3d
parent 30c9b0db0ba5939c2949915c9f68c450700d7254
5 files changed +151 -151
added radicle-cli/examples/rad-cob-log.md
@@ -0,0 +1,141 @@
+
Handle arbitrary COBs.
+

+
First create an issue.
+

+
```
+
$ rad issue open --title "flux capacitor underpowered" --description "Flux capacitor power requirements exceed current supply" --no-announce
+
╭─────────────────────────────────────────────────────────╮
+
│ Title   flux capacitor underpowered                     │
+
│ Issue   d87dcfe8c2b3200e78b128d9b959cfdf7063fefe        │
+
│ Author  z6MknSL…StBU8Vi (you)                           │
+
│ Status  open                                            │
+
│                                                         │
+
│ Flux capacitor power requirements exceed current supply │
+
╰─────────────────────────────────────────────────────────╯
+
```
+

+
The issue is now listed under our project.
+

+
```
+
$ rad issue list
+
╭───────────────────────────────────────────────────────────────────────────────────────────────────╮
+
│ ●   ID        Title                         Author                    Labels   Assignees   Opened │
+
├───────────────────────────────────────────────────────────────────────────────────────────────────┤
+
│ ●   d87dcfe   flux capacitor underpowered   z6MknSL…StBU8Vi   (you)                        now    │
+
╰───────────────────────────────────────────────────────────────────────────────────────────────────╯
+
```
+

+
Let's create a patch, too.
+

+
```
+
$ git checkout -b flux-capacitor-power
+
$ touch REQUIREMENTS
+
$ git add REQUIREMENTS
+
$ git commit -v -m "Define power requirements"
+
[flux-capacitor-power 3e674d1] Define power requirements
+
 1 file changed, 0 insertions(+), 0 deletions(-)
+
 create mode 100644 REQUIREMENTS
+
$ git push rad -o patch.message="Define power requirements" -o patch.message="See details." HEAD:refs/patches
+
```
+

+
Patch can be listed.
+

+
```
+
$ rad patch
+
╭──────────────────────────────────────────────────────────────────────────────────────────────────╮
+
│ ●  ID       Title                      Author                  Reviews  Head     +   -   Updated │
+
├──────────────────────────────────────────────────────────────────────────────────────────────────┤
+
│ ●  aa45913  Define power requirements  z6MknSL…StBU8Vi  (you)  -        3e674d1  +0  -0  now     │
+
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
+
```
+

+
Both issue and patch COBs can be listed.
+

+
```
+
$ rad cob list --repo rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji --type xyz.radicle.issue
+
d87dcfe8c2b3200e78b128d9b959cfdf7063fefe
+
$ rad cob list --repo rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji --type xyz.radicle.patch
+
aa45913e757cacd46972733bddee5472c78fa32a
+
```
+

+
We can look at the issue COB.
+

+
```
+
$ rad cob log --repo rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji --type xyz.radicle.issue --object d87dcfe8c2b3200e78b128d9b959cfdf7063fefe
+
commit   d87dcfe8c2b3200e78b128d9b959cfdf7063fefe
+
resource 0656c217f917c3e06234771e9ecae53aba5e173e
+
author   z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
+
date     Thu, 15 Dec 2022 17:28:04 +0000
+

+
    {
+
      "body": "Flux capacitor power requirements exceed current supply",
+
      "type": "comment"
+
    }
+

+
    {
+
      "title": "flux capacitor underpowered",
+
      "type": "edit"
+
    }
+

+
```
+

+
We can look at the patch COB too.
+

+
```
+
$ rad cob log --repo rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji --type xyz.radicle.patch --object aa45913e757cacd46972733bddee5472c78fa32a
+
commit   aa45913e757cacd46972733bddee5472c78fa32a
+
resource 0656c217f917c3e06234771e9ecae53aba5e173e
+
rel      3e674d1a1df90807e934f9ae5da2591dd6848a33
+
rel      f2de534b5e81d7c6e2dcaf58c3dd91573c0a0354
+
author   z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
+
date     Thu, 15 Dec 2022 17:28:04 +0000
+

+
    {
+
      "base": "f2de534b5e81d7c6e2dcaf58c3dd91573c0a0354",
+
      "description": "See details.",
+
      "oid": "3e674d1a1df90807e934f9ae5da2591dd6848a33",
+
      "type": "revision"
+
    }
+

+
    {
+
      "target": "delegates",
+
      "title": "Define power requirements",
+
      "type": "edit"
+
    }
+

+
```
+

+
Finally let's updated the issue and see the `parent` header:
+

+
```
+
$ rad issue label d87dcfe --add bug --no-announce
+
$ rad cob log --repo rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji --type xyz.radicle.issue --object d87dcfe8c2b3200e78b128d9b959cfdf7063fefe
+
commit   abec0a9f3c945594c4e78d24d8ec679e56b22b79
+
resource 0656c217f917c3e06234771e9ecae53aba5e173e
+
parent   d87dcfe8c2b3200e78b128d9b959cfdf7063fefe
+
author   z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
+
date     Thu, 15 Dec 2022 17:28:04 +0000
+

+
    {
+
      "labels": [
+
        "bug"
+
      ],
+
      "type": "label"
+
    }
+

+
commit   d87dcfe8c2b3200e78b128d9b959cfdf7063fefe
+
resource 0656c217f917c3e06234771e9ecae53aba5e173e
+
author   z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
+
date     Thu, 15 Dec 2022 17:28:04 +0000
+

+
    {
+
      "body": "Flux capacitor power requirements exceed current supply",
+
      "type": "comment"
+
    }
+

+
    {
+
      "title": "flux capacitor underpowered",
+
      "type": "edit"
+
    }
+

+
```
deleted radicle-cli/examples/rad-cob.md
@@ -1,141 +0,0 @@
-
Handle arbitrary COBs.
-

-
First create an issue.
-

-
```
-
$ rad issue open --title "flux capacitor underpowered" --description "Flux capacitor power requirements exceed current supply" --no-announce
-
╭─────────────────────────────────────────────────────────╮
-
│ Title   flux capacitor underpowered                     │
-
│ Issue   d87dcfe8c2b3200e78b128d9b959cfdf7063fefe        │
-
│ Author  z6MknSL…StBU8Vi (you)                           │
-
│ Status  open                                            │
-
│                                                         │
-
│ Flux capacitor power requirements exceed current supply │
-
╰─────────────────────────────────────────────────────────╯
-
```
-

-
The issue is now listed under our project.
-

-
```
-
$ rad issue list
-
╭───────────────────────────────────────────────────────────────────────────────────────────────────╮
-
│ ●   ID        Title                         Author                    Labels   Assignees   Opened │
-
├───────────────────────────────────────────────────────────────────────────────────────────────────┤
-
│ ●   d87dcfe   flux capacitor underpowered   z6MknSL…StBU8Vi   (you)                        now    │
-
╰───────────────────────────────────────────────────────────────────────────────────────────────────╯
-
```
-

-
Let's create a patch, too.
-

-
```
-
$ git checkout -b flux-capacitor-power
-
$ touch REQUIREMENTS
-
$ git add REQUIREMENTS
-
$ git commit -v -m "Define power requirements"
-
[flux-capacitor-power 3e674d1] Define power requirements
-
 1 file changed, 0 insertions(+), 0 deletions(-)
-
 create mode 100644 REQUIREMENTS
-
$ git push rad -o patch.message="Define power requirements" -o patch.message="See details." HEAD:refs/patches
-
```
-

-
Patch can be listed.
-

-
```
-
$ rad patch
-
╭──────────────────────────────────────────────────────────────────────────────────────────────────╮
-
│ ●  ID       Title                      Author                  Reviews  Head     +   -   Updated │
-
├──────────────────────────────────────────────────────────────────────────────────────────────────┤
-
│ ●  aa45913  Define power requirements  z6MknSL…StBU8Vi  (you)  -        3e674d1  +0  -0  now     │
-
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
-
```
-

-
Both issue and patch COBs can be listed.
-

-
```
-
$ rad cob list --repo rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji --type xyz.radicle.issue
-
d87dcfe8c2b3200e78b128d9b959cfdf7063fefe
-
$ rad cob list --repo rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji --type xyz.radicle.patch
-
aa45913e757cacd46972733bddee5472c78fa32a
-
```
-

-
We can look at the issue COB.
-

-
```
-
$ rad cob show --repo rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji --type xyz.radicle.issue --object d87dcfe8c2b3200e78b128d9b959cfdf7063fefe
-
commit   d87dcfe8c2b3200e78b128d9b959cfdf7063fefe
-
resource 0656c217f917c3e06234771e9ecae53aba5e173e
-
author   z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
-
date     Thu, 15 Dec 2022 17:28:04 +0000
-

-
    {
-
      "body": "Flux capacitor power requirements exceed current supply",
-
      "type": "comment"
-
    }
-

-
    {
-
      "title": "flux capacitor underpowered",
-
      "type": "edit"
-
    }
-

-
```
-

-
We can look at the patch COB too.
-

-
```
-
$ rad cob show --repo rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji --type xyz.radicle.patch --object aa45913e757cacd46972733bddee5472c78fa32a
-
commit   aa45913e757cacd46972733bddee5472c78fa32a
-
resource 0656c217f917c3e06234771e9ecae53aba5e173e
-
rel      3e674d1a1df90807e934f9ae5da2591dd6848a33
-
rel      f2de534b5e81d7c6e2dcaf58c3dd91573c0a0354
-
author   z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
-
date     Thu, 15 Dec 2022 17:28:04 +0000
-

-
    {
-
      "base": "f2de534b5e81d7c6e2dcaf58c3dd91573c0a0354",
-
      "description": "See details.",
-
      "oid": "3e674d1a1df90807e934f9ae5da2591dd6848a33",
-
      "type": "revision"
-
    }
-

-
    {
-
      "target": "delegates",
-
      "title": "Define power requirements",
-
      "type": "edit"
-
    }
-

-
```
-

-
Finally let's updated the issue and see the `parent` header:
-

-
```
-
$ rad issue label d87dcfe --add bug --no-announce
-
$ rad cob show --repo rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji --type xyz.radicle.issue --object d87dcfe8c2b3200e78b128d9b959cfdf7063fefe
-
commit   abec0a9f3c945594c4e78d24d8ec679e56b22b79
-
resource 0656c217f917c3e06234771e9ecae53aba5e173e
-
parent   d87dcfe8c2b3200e78b128d9b959cfdf7063fefe
-
author   z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
-
date     Thu, 15 Dec 2022 17:28:04 +0000
-

-
    {
-
      "labels": [
-
        "bug"
-
      ],
-
      "type": "label"
-
    }
-

-
commit   d87dcfe8c2b3200e78b128d9b959cfdf7063fefe
-
resource 0656c217f917c3e06234771e9ecae53aba5e173e
-
author   z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
-
date     Thu, 15 Dec 2022 17:28:04 +0000
-

-
    {
-
      "body": "Flux capacitor power requirements exceed current supply",
-
      "type": "comment"
-
    }
-

-
    {
-
      "title": "flux capacitor underpowered",
-
      "type": "edit"
-
    }
-

-
```
modified radicle-cli/examples/rad-id.md
@@ -93,7 +93,7 @@ $ rad inspect --identity

We can also look at the document's COB directly:
```
-
$ rad cob show --object 0656c217f917c3e06234771e9ecae53aba5e173e --type xyz.radicle.id --repo rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji
+
$ rad cob log --object 0656c217f917c3e06234771e9ecae53aba5e173e --type xyz.radicle.id --repo rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji
commit   0ca42d376bd566631083c8913cf86bec722da392
parent   0656c217f917c3e06234771e9ecae53aba5e173e
author   z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
modified radicle-cli/src/commands/cob.rs
@@ -22,12 +22,12 @@ Usage

    rad cob <command> [<option>...]
    rad cob list --repo <rid> --type <typename>
-
    rad cob show --repo <rid> --type <typename> --object <oid>
+
    rad cob log  --repo <rid> --type <typename> --object <oid>

Commands

    list       List all COBs of a given type (--object is not needed)
-
    show       Show a COB as raw operations
+
    log        Print a log of all raw operations on a COB

Options

@@ -37,12 +37,12 @@ Options

enum OperationName {
    List,
-
    Show,
+
    Log,
}

enum Operation {
    List,
-
    Show(Rev),
+
    Log(Rev),
}

pub struct Options {
@@ -64,8 +64,8 @@ impl Args for Options {
        while let Some(arg) = parser.next()? {
            match arg {
                Value(val) if op.is_none() => match val.to_string_lossy().as_ref() {
-
                    "l" | "list" => op = Some(OperationName::List),
-
                    "s" | "show" => op = Some(OperationName::Show),
+
                    "list" => op = Some(OperationName::List),
+
                    "log" => op = Some(OperationName::Log),
                    unknown => anyhow::bail!("unknown operation '{unknown}'"),
                },
                Long("type") | Short('t') => {
@@ -99,7 +99,7 @@ impl Args for Options {
                op: {
                    match op.ok_or_else(|| anyhow!("a command must be specified"))? {
                        OperationName::List => Operation::List,
-
                        OperationName::Show => Operation::Show(oid.ok_or_else(|| {
+
                        OperationName::Log => Operation::Log(oid.ok_or_else(|| {
                            anyhow!("an object id must be specified with `--object")
                        })?),
                    }
@@ -126,7 +126,7 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
                println!("{}", cob.id);
            }
        }
-
        Operation::Show(oid) => {
+
        Operation::Log(oid) => {
            let oid = oid.resolve(&repo.backend)?;
            let ops = cob::store::ops(&oid, &options.type_name, &repo)?;

modified radicle-cli/tests/commands.rs
@@ -166,7 +166,7 @@ fn rad_cob() {
    fixtures::repository(&working);

    test("examples/rad-init.md", &working, Some(home), []).unwrap();
-
    test("examples/rad-cob.md", &working, Some(home), []).unwrap();
+
    test("examples/rad-cob-log.md", &working, Some(home), []).unwrap();
}

#[test]