/ radicle-cli / examples / rad-patch-pull-update.md
rad-patch-pull-update.md
  1  Let's look at how patch updates work.
  2  
  3  Alice creates a project and Bob clones it.
  4  
  5  ``` ~alice
  6  $ rad init --name heartwood --description "radicle heartwood protocol & stack" --no-confirm --public
  7  
  8  Initializing public radicle ๐Ÿ‘พ project in .
  9  
 10  โœ“ Project heartwood created.
 11  
 12  Your project's Repository ID (RID) is rad:zhbMU4DUXrzB8xT6qAJh6yZ7bFMK.
 13  You can show it any time by running `rad .` from this directory.
 14  
 15  โœ“ Project successfully announced.
 16  
 17  Your project has been announced to the network and is now discoverable by peers.
 18  To push changes, run `git push`.
 19  ```
 20  
 21  ``` ~bob
 22  $ rad clone rad:zhbMU4DUXrzB8xT6qAJh6yZ7bFMK
 23  โœ“ Tracking relationship established for rad:zhbMU4DUXrzB8xT6qAJh6yZ7bFMK with scope 'all'
 24  โœ“ Fetching rad:zhbMU4DUXrzB8xT6qAJh6yZ7bFMK from z6MknSLโ€ฆStBU8Vi..
 25  โœ“ Forking under z6Mkt67โ€ฆv4N1tRk..
 26  โœ“ Creating checkout in ./heartwood..
 27  โœ“ Remote alice@z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi added
 28  โœ“ Remote-tracking branch alice@z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi/master created for z6MknSLโ€ฆStBU8Vi
 29  โœ“ Repository successfully cloned under [..]/heartwood/
 30  โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
 31  โ”‚ heartwood                          โ”‚
 32  โ”‚ radicle heartwood protocol & stack โ”‚
 33  โ”‚ 0 issues ยท 0 patches               โ”‚
 34  โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
 35  Run `cd ./heartwood` to go to the project directory.
 36  ```
 37  
 38  We wait for Alice to sync our fork.
 39  
 40  ``` ~bob
 41  $ rad node events -n 1 --timeout 1
 42  {"type":"refsSynced","remote":"z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi","rid":"rad:zhbMU4DUXrzB8xT6qAJh6yZ7bFMK"}
 43  ```
 44  
 45  Bob then opens a patch.
 46  
 47  ``` ~bob (stderr)
 48  $ cd heartwood
 49  $ git checkout -b bob/feature -q
 50  $ git commit --allow-empty -m "Bob's commit #1" -q
 51  $ git push rad -o sync -o patch.message="Bob's patch" HEAD:refs/patches
 52  โœ“ Patch 6d260fc8388e74d8fefb5dabc5a798e125ec3cf9 opened
 53  โœ“ Synced with 1 node(s)
 54  To rad://zhbMU4DUXrzB8xT6qAJh6yZ7bFMK/z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk
 55   * [new reference]   HEAD -> refs/patches
 56  ```
 57  ``` ~bob
 58  $ git status --short --branch
 59  ## bob/feature...rad/patches/6d260fc8388e74d8fefb5dabc5a798e125ec3cf9
 60  ```
 61  
 62  Alice checks it out.
 63  
 64  ``` ~alice
 65  $ rad patch checkout 6d260fc8388e74d8fefb5dabc5a798e125ec3cf9
 66  โœ“ Switched to branch patch/6d260fc
 67  โœ“ Branch patch/6d260fc setup to track rad/patches/6d260fc8388e74d8fefb5dabc5a798e125ec3cf9
 68  $ git show
 69  commit bdcdb30b3c0f513620dd0f1c24ff8f4f71de956b
 70  Author: radicle <radicle@localhost>
 71  Date:   Thu Dec 15 17:28:04 2022 +0000
 72  
 73      Bob's commit #1
 74  ```
 75  
 76  Bob then updates the patch.
 77  
 78  ``` ~bob (stderr)
 79  $ git commit --allow-empty -m "Bob's commit #2" -q
 80  $ git push rad -o sync -o patch.message="Updated."
 81  โœ“ Patch 6d260fc updated to 750081b35a3f831f428653bd2240eb4674ccae71
 82  โœ“ Synced with 1 node(s)
 83  To rad://zhbMU4DUXrzB8xT6qAJh6yZ7bFMK/z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk
 84     bdcdb30..cad2666  bob/feature -> patches/6d260fc8388e74d8fefb5dabc5a798e125ec3cf9
 85  ```
 86  
 87  Alice pulls the update.
 88  
 89  ``` ~alice
 90  $ rad patch show 6d260fc
 91  โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
 92  โ”‚ Title    Bob's patch                                                โ”‚
 93  โ”‚ Patch    6d260fc8388e74d8fefb5dabc5a798e125ec3cf9                   โ”‚
 94  โ”‚ Author   bob z6Mkt67โ€ฆv4N1tRk                                        โ”‚
 95  โ”‚ Head     cad2666a8a2250e4dee175ed5044be2c251ff08b                   โ”‚
 96  โ”‚ Commits  ahead 2, behind 0                                          โ”‚
 97  โ”‚ Status   open                                                       โ”‚
 98  โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
 99  โ”‚ cad2666 Bob's commit #2                                             โ”‚
100  โ”‚ bdcdb30 Bob's commit #1                                             โ”‚
101  โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
102  โ”‚ โ— opened by bob z6Mkt67โ€ฆv4N1tRk now                                 โ”‚
103  โ”‚ โ†‘ updated to 750081b35a3f831f428653bd2240eb4674ccae71 (cad2666) now โ”‚
104  โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
105  $ git ls-remote rad
106  f2de534b5e81d7c6e2dcaf58c3dd91573c0a0354	refs/heads/master
107  cad2666a8a2250e4dee175ed5044be2c251ff08b	refs/heads/patches/6d260fc8388e74d8fefb5dabc5a798e125ec3cf9
108  ```
109  ``` ~alice
110  $ git fetch rad
111  $ git status --short --branch
112  ## patch/6d260fc...rad/patches/6d260fc8388e74d8fefb5dabc5a798e125ec3cf9 [behind 1]
113  ```
114  ``` ~alice
115  $ git pull
116  Updating bdcdb30..cad2666
117  Fast-forward
118  ```
119  ``` ~alice
120  $ git show
121  commit cad2666a8a2250e4dee175ed5044be2c251ff08b
122  Author: radicle <radicle@localhost>
123  Date:   Thu Dec 15 17:28:04 2022 +0000
124  
125      Bob's commit #2
126  ```