Files
heartwood/radicle-cli/examples/rad-patch.md
T
Alexis Sellier 3bd5589b1a cob: Stabilize formats
> I'm going to be making a set of breaking changes to COBs in order to
stabilize the data formats. This is hopefully a one-time change that
bundles various breaking changes.

All COBs have been reworked: issue, patch, id.

The changes included are:

* Revise the assign and tag actions to take a single list of
  assignees/tags to set, instead of an "add" and a "remove" list. This
  makes API usage simpler when editing issues, and simplifies the apply
  function
* Rename "tags" to "labels", and the tag action to label. This is
  because tag is confusing in the context of git, as it could mean a git
  tag. Using label removes that confusion.
* Use DIDs instead of PublicKeys for assignees -- this is more
  future-proof
* Modify the manifest file format in the COB tree. Mainly, remove the
  `history_type` key which is redundant, and use camelCase for keys
* Flatten the `Thread` actions into the parent action type
* Ensure that operations on redacted objects do not fail, since
  redactions could have happened concurrently
* Use a consistent naming scheme for actions, using `.` as separator
* Consolidate comment types and remove `CodeComment`, by adding an
  optional `location` field to `Comment`
* Add many placeholder actions that are not yet implemented

To preserve backwards compatibility, a `legacy` module is created with
the old `apply` function. When loading the manifest, we check whether it
is a legacy COB or a "stable" COB, and in the legacy case, use the
legacy code to materialize the state and then convert the object into
the stable type. Eventually, we'll delete the legacy code.
2023-08-07 11:05:14 +02:00

10 KiB

When contributing to another's project, it is common for the contribution to be of many commits and involve a discussion with the project's maintainer. This is supported via Radicle's patches.

Here we give a brief overview for using patches in our hypothetical car scenario. It turns out instructions containing the power requirements were missing from the project.

$ git checkout -b flux-capacitor-power
$ touch REQUIREMENTS

Here the instructions are added to the project's README for 1.21 gigawatts and commit the changes to git.

$ 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

Once the code is ready, we open (or create) a patch with our changes for the project.

$ git push rad -o patch.message="Define power requirements" -o patch.message="See details." HEAD:refs/patches
✓ Patch 73b73f376e93e09e0419664766ac9e433bf7d389 opened
To rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
 * [new reference]   HEAD -> refs/patches

It will now be listed as one of the project's open patches.

$ rad patch
╭──────────────────────────────────────────────────────────────────────────────────────────────╮
│ ●  ID       Title                      Author                  Head     +   -   Updated      │
├──────────────────────────────────────────────────────────────────────────────────────────────┤
│ ●  73b73f3  Define power requirements  z6MknSL…StBU8Vi  (you)  3e674d1  +0  -0  [   ...    ] │
╰──────────────────────────────────────────────────────────────────────────────────────────────╯
$ rad patch show 73b73f376e93e09e0419664766ac9e433bf7d389 -p
╭────────────────────────────────────────────────────────────────────╮
│ Title     Define power requirements                                │
│ Patch     73b73f376e93e09e0419664766ac9e433bf7d389                 │
│ Author    did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi │
│ Head      3e674d1a1df90807e934f9ae5da2591dd6848a33                 │
│ Branches  flux-capacitor-power                                     │
│ Commits   ahead 1, behind 0                                        │
│ Status    open                                                     │
│                                                                    │
│ See details.                                                       │
├────────────────────────────────────────────────────────────────────┤
│ 3e674d1 Define power requirements                                  │
├────────────────────────────────────────────────────────────────────┤
│ ● opened by (you) [    ...    ]                                    │
╰────────────────────────────────────────────────────────────────────╯

commit 3e674d1a1df90807e934f9ae5da2591dd6848a33
Author: radicle <radicle@localhost>
Date:   Thu Dec 15 17:28:04 2022 +0000

    Define power requirements

diff --git a/REQUIREMENTS b/REQUIREMENTS
new file mode 100644
index 0000000..e69de29

We can also see that it set an upstream for our patch branch:

$ git branch -vv
* flux-capacitor-power 3e674d1 [rad/patches/73b73f376e93e09e0419664766ac9e433bf7d389] Define power requirements
  master               f2de534 [rad/master] Second commit

Wait, let's add a README too! Just for fun.

$ touch README.md
$ git add README.md
$ git commit --message "Add README, just for the fun"
[flux-capacitor-power 27857ec] Add README, just for the fun
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 README.md
$ git push rad -o patch.message="Add README, just for the fun"
✓ Patch 73b73f3 updated to 5605784ae81dad91ba47ea55e19dd16f6280d44b
To rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
   3e674d1..27857ec  flux-capacitor-power -> patches/73b73f376e93e09e0419664766ac9e433bf7d389

And let's leave a quick comment for our team:

$ rad comment 73b73f376e93e09e0419664766ac9e433bf7d389 --message 'I cannot wait to get back to the 90s!'
de198e9b1613d827ce294a5b36cecdb8e65abcf1
$ rad comment 73b73f376e93e09e0419664766ac9e433bf7d389 --message 'I cannot wait to get back to the 90s!' --reply-to de198e9b1613d827ce294a5b36cecdb8e65abcf1
bd53b38140cf8249ef31c7464d35a4c960258e3f

Now, let's checkout the patch that we just created:

$ rad patch checkout 73b73f3
✓ Switched to branch patch/73b73f3
✓ Branch patch/73b73f3 setup to track rad/patches/73b73f376e93e09e0419664766ac9e433bf7d389

We can also add a review verdict as such:

$ rad review 73b73f376e93e09e0419664766ac9e433bf7d389 --accept --no-message --no-sync
✓ Patch 73b73f3 accepted

Showing the patch list now will reveal the favorable verdict:

$ rad patch show 73b73f3
╭──────────────────────────────────────────────────────────────────────────────╮
│ Title     Define power requirements                                          │
│ Patch     73b73f376e93e09e0419664766ac9e433bf7d389                           │
│ Author    did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi           │
│ Head      27857ec9eb04c69cacab516e8bf4b5fd36090f66                           │
│ Branches  flux-capacitor-power, patch/73b73f3                                │
│ Commits   ahead 2, behind 0                                                  │
│ Status    open                                                               │
│                                                                              │
│ See details.                                                                 │
├──────────────────────────────────────────────────────────────────────────────┤
│ 27857ec Add README, just for the fun                                         │
│ 3e674d1 Define power requirements                                            │
├──────────────────────────────────────────────────────────────────────────────┤
│ ● opened by (you) [   ...    ]                                               │
│ ↑ updated to 5605784ae81dad91ba47ea55e19dd16f6280d44b (27857ec) [   ...    ] │
│ ✓ accepted by (you) [   ...    ]                                             │
╰──────────────────────────────────────────────────────────────────────────────╯

If you make a mistake on the patch description, you can always change it!

$ rad patch edit 73b73f3 --message "Define power requirements" --message "Add requirements file"
$ rad patch show 73b73f3
╭──────────────────────────────────────────────────────────────────────────────╮
│ Title     Define power requirements                                          │
│ Patch     73b73f376e93e09e0419664766ac9e433bf7d389                           │
│ Author    did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi           │
│ Head      27857ec9eb04c69cacab516e8bf4b5fd36090f66                           │
│ Branches  flux-capacitor-power, patch/73b73f3                                │
│ Commits   ahead 2, behind 0                                                  │
│ Status    open                                                               │
│                                                                              │
│ Add requirements file                                                        │
├──────────────────────────────────────────────────────────────────────────────┤
│ 27857ec Add README, just for the fun                                         │
│ 3e674d1 Define power requirements                                            │
├──────────────────────────────────────────────────────────────────────────────┤
│ ● opened by (you) [   ...    ]                                               │
│ ↑ updated to 5605784ae81dad91ba47ea55e19dd16f6280d44b (27857ec) [   ...    ] │
│ ✓ accepted by (you) [   ...    ]                                             │
╰──────────────────────────────────────────────────────────────────────────────╯