Files
heartwood/radicle-cli/examples/rad-patch-update.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

4.4 KiB

Let's explore the rad patch update plumbing command. First we create a patch:

$ git checkout -q -b feature/1
$ git commit -q -m "Not a real change" --allow-empty
$ git push rad HEAD:refs/patches
✓ Patch ea6fa6c274c55d0f4fdf203a192cbf1330b51221 opened
To rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
 * [new reference]   HEAD -> refs/patches
$ rad patch show ea6fa6c274c55d0f4fdf203a192cbf1330b51221
╭────────────────────────────────────────────────────────────────────╮
│ Title     Not a real change                                        │
│ Patch     ea6fa6c274c55d0f4fdf203a192cbf1330b51221                 │
│ Author    did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi │
│ Head      51b2f0f77b9849bfaa3e9d3ff68ee2f57771d20c                 │
│ Branches  feature/1                                                │
│ Commits   ahead 1, behind 0                                        │
│ Status    open                                                     │
├────────────────────────────────────────────────────────────────────┤
│ 51b2f0f Not a real change                                          │
├────────────────────────────────────────────────────────────────────┤
│ ● opened by (you) [           ...              ]                   │
╰────────────────────────────────────────────────────────────────────╯

We can make some changes to the repository:

$ git mv README README.md
$ git commit -q -m "Rename readme file"

Let's push the changes, but not to the magic ref, that way the push doesn't update our patch:

$ git push rad HEAD:refs/heads/feature/1

Now, instead of using git push to update the patch, as we normally would, we run:

$ rad patch update ea6fa6c274c55d0f4fdf203a192cbf1330b51221 -m "Updated patch"
59bbb5c5d3c9f18a686113e6354b1372eebafda4

The command outputs the new Revision ID, which we can now see here:

$ rad patch show ea6fa6c274c55d0f4fdf203a192cbf1330b51221
╭──────────────────────────────────────────────────────────────────────────────╮
│ Title     Not a real change                                                  │
│ Patch     ea6fa6c274c55d0f4fdf203a192cbf1330b51221                           │
│ Author    did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi           │
│ Head      4d272148458a17620541555b1f0905c01658aa9f                           │
│ Branches  feature/1                                                          │
│ Commits   ahead 2, behind 0                                                  │
│ Status    open                                                               │
├──────────────────────────────────────────────────────────────────────────────┤
│ 4d27214 Rename readme file                                                   │
│ 51b2f0f Not a real change                                                    │
├──────────────────────────────────────────────────────────────────────────────┤
│ ● opened by (you) [                                ...   ]                   │
│ ↑ updated to 59bbb5c5d3c9f18a686113e6354b1372eebafda4 (4d27214) [    ...   ] │
╰──────────────────────────────────────────────────────────────────────────────╯