Files
heartwood/radicle-cli/examples/rad-review-by-hunk.md
T
cloudhead a46bcb2247 cob: Distinguish between commit parents
Previously, COB change commits would not distinguish between their
parents. This means that they would try to load source code commits
(eg. for patch COBs) and then fail since those commits wouldn't have a
manifest or `Rad-Resource`.

We introduce a backwards compatible change here which is that parent
oids that are not COB commits are accompanied by a commit trailer called
`Rad-Related`. This is for all related content that should be pulled in
but is not part of the change graph proper.

When building the change graph, we simply ignore commits that are marked
as "related".
2024-01-22 21:20:01 +01:00

4.2 KiB

Let's start by creating some files we will patch:

Classics
--------
Salmon Tartare
Mac & Cheese

Comfort Food
------------
Reuben Sandwich
Club Sandwich
Fried Shrimp Basket

Sides
-----
French Fries
Notes on how to prepare food go here.
*.draft

Now let's commit and push them:

$ git add MENU.txt INSTRUCTIONS.txt .gitignore
$ git commit -q -a -m "Add files"
$ git push rad master

We can now make some changes and create a patch:

$ sed -i '$a Garlic Green Beans' MENU.txt
$ sed -i '3i\Baked Brie' MENU.txt
$ sed -i 's/French Fries/French Fries!/' MENU.txt
$ rm .gitignore
$ mkdir notes
$ mv INSTRUCTIONS.txt notes/
All food is served as-is, with no warranty!
$ git checkout -q -b patch/1
$ git add .
$ git status --short
D  .gitignore
A  DISCLAIMER.txt
M  MENU.txt
R  INSTRUCTIONS.txt -> notes/INSTRUCTIONS.txt
$ git commit -q -m "Update files"
$ git push rad HEAD:refs/patches
✓ Patch 09f4d8b2335190a38d462373f197492ce3e9c3ca opened
To rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
 * [new reference]   HEAD -> refs/patches

Finally, we do a review of the patch by hunk. The output of this command should match git diff master -W100% -U5 --patience:

$ rad patch review --patch -U5 09f4d8b2335190a38d462373f197492ce3e9c3ca --no-announce
diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index 7937fb3..0000000
--- a/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-*.draft
diff --git a/DISCLAIMER.txt b/DISCLAIMER.txt
new file mode 100644
index 0000000..2b5bd86
--- /dev/null
+++ b/DISCLAIMER.txt
@@ -0,0 +1 @@
+All food is served as-is, with no warranty!
diff --git a/MENU.txt b/MENU.txt
index 867958c..3af9741 100644
--- a/MENU.txt
+++ b/MENU.txt
@@ -1,7 +1,8 @@
 Classics
 --------
+Baked Brie
 Salmon Tartare
 Mac & Cheese
[..]
 Comfort Food
 ------------
@@ -9,6 +10,7 @@ Reuben Sandwich
 Club Sandwich
 Fried Shrimp Basket
[..]
 Sides
 -----
-French Fries
+French Fries!
+Garlic Green Beans
diff --git a/INSTRUCTIONS.txt b/notes/INSTRUCTIONS.txt
similarity index 100%
rename from INSTRUCTIONS.txt
rename to notes/INSTRUCTIONS.txt

Now let's accept these hunks one by one..

$ rad patch review --patch --accept --hunk 1 09f4d8b2335190a38d462373f197492ce3e9c3ca --no-announce
✓ Loaded existing review ([..]) for patch 09f4d8b2335190a38d462373f197492ce3e9c3ca
diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index 7937fb3..0000000
--- a/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-*.draft
$ rad patch review --patch --accept --hunk 1 09f4d8b2335190a38d462373f197492ce3e9c3ca --no-announce
✓ Loaded existing review ([..]) for patch 09f4d8b2335190a38d462373f197492ce3e9c3ca
diff --git a/DISCLAIMER.txt b/DISCLAIMER.txt
new file mode 100644
index 0000000..2b5bd86
--- /dev/null
+++ b/DISCLAIMER.txt
@@ -0,0 +1 @@
+All food is served as-is, with no warranty!
$ rad patch review --patch --accept -U3 --hunk 1 09f4d8b2335190a38d462373f197492ce3e9c3ca --no-announce
✓ Loaded existing review ([..]) for patch 09f4d8b2335190a38d462373f197492ce3e9c3ca
diff --git a/MENU.txt b/MENU.txt
index 867958c..3af9741 100644
--- a/MENU.txt
+++ b/MENU.txt
@@ -1,5 +1,6 @@
 Classics
 --------
+Baked Brie
 Salmon Tartare
 Mac & Cheese
[..]
$ rad patch review --patch --accept -U3 --hunk 1 09f4d8b2335190a38d462373f197492ce3e9c3ca --no-announce
✓ Loaded existing review ([..]) for patch 09f4d8b2335190a38d462373f197492ce3e9c3ca
diff --git a/MENU.txt b/MENU.txt
index 4e2e828..3af9741 100644
--- a/MENU.txt
+++ b/MENU.txt
@@ -12,4 +12,5 @@ Fried Shrimp Basket
[..]
 Sides
 -----
-French Fries
+French Fries!
+Garlic Green Beans
$ rad patch review --patch --accept --hunk 1 09f4d8b2335190a38d462373f197492ce3e9c3ca --no-announce
✓ Loaded existing review ([..]) for patch 09f4d8b2335190a38d462373f197492ce3e9c3ca
diff --git a/INSTRUCTIONS.txt b/notes/INSTRUCTIONS.txt
similarity index 100%
rename from INSTRUCTIONS.txt
rename to notes/INSTRUCTIONS.txt
$ rad patch review --patch --accept --hunk 1 09f4d8b2335190a38d462373f197492ce3e9c3ca --no-announce
✓ Loaded existing review ([..]) for patch 09f4d8b2335190a38d462373f197492ce3e9c3ca
✓ All hunks have been reviewed