From 3d803b249804637b73d74252a7e16ca80d3ae849 Mon Sep 17 00:00:00 2001 From: Alexis Sellier Date: Wed, 7 Jun 2023 15:57:11 +0200 Subject: [PATCH] cli: Remove `rad patch open` Remove this command in favor of the `git push` flow. We also remove the `rad/patches` remote configuration which wasn't working properly with `git fetch --all`. --- radicle-cli/examples/rad-patch-via-push.md | 12 +- radicle-cli/examples/rad-patch.md | 18 +-- radicle-cli/examples/rad-remote.md | 7 +- .../workflow/4-patching-contributor.md | 30 ++-- .../workflow/5-patching-maintainer.md | 16 +-- radicle-cli/src/commands/clone.rs | 3 +- radicle-cli/src/commands/patch.rs | 43 +----- radicle-cli/src/commands/patch/common.rs | 17 --- radicle-cli/src/commands/patch/create.rs | 134 ------------------ radicle-cli/src/commands/remote/list.rs | 17 +-- radicle/src/git.rs | 27 ---- radicle/src/rad.rs | 13 -- 12 files changed, 41 insertions(+), 296 deletions(-) delete mode 100644 radicle-cli/src/commands/patch/create.rs diff --git a/radicle-cli/examples/rad-patch-via-push.md b/radicle-cli/examples/rad-patch-via-push.md index dbb495c2..de81e068 100644 --- a/radicle-cli/examples/rad-patch-via-push.md +++ b/radicle-cli/examples/rad-patch-via-push.md @@ -68,13 +68,12 @@ $ git ls-remote rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6MknSLrJoTcukLrE435hVNQT4JU 2647168c23e7c2b2c1936d695443944e143bc3f7 refs/cobs/xyz.radicle.patch/2647168c23e7c2b2c1936d695443944e143bc3f7 ``` -We can also create patches by pushing to the `rad/patches` remote. It's a bit -simpler: +We can create another patch: ``` (stderr) $ git checkout -b feature/2 -q master $ git commit -a -m "Add more things" -q --allow-empty -$ git push rad/patches +$ git push rad HEAD:refs/patches ✓ Patch b8ab1c99c1c8205680a3494f04fb3934ec738ddd opened To rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi * [new reference] HEAD -> refs/patches @@ -101,13 +100,6 @@ $ rad patch ╰────────────────────────────────────────────────────────────────────────────────────╯ ``` -Note that we can't fetch from `rad/patches`: - -``` (stderr) (fail) -$ git fetch rad/patches -fatal: couldn't find remote ref refs/patches -``` - To update our patch, we simply push commits to the upstream branch: ``` diff --git a/radicle-cli/examples/rad-patch.md b/radicle-cli/examples/rad-patch.md index 4f82b708..22e0cdb3 100644 --- a/radicle-cli/examples/rad-patch.md +++ b/radicle-cli/examples/rad-patch.md @@ -24,17 +24,11 @@ $ git commit -v -m "Define power requirements" Once the code is ready, we open (or create) a patch with our changes for the project. -``` -$ rad patch open --message "Define power requirements" --message "See details." -master <- z6MknSL…StBU8Vi/flux-capacitor-power (3e674d1) -1 commit(s) ahead, 0 commit(s) behind - -3e674d1 Define power requirements - -✓ Patch 077e4bbe9a6e5546f400ef5951768c37a76f13a4 created - -To publish your patch to the network, run: - git push rad +``` (stderr) +$ git push rad -o patch.message="Define power requirements" -o patch.message="See details." HEAD:refs/patches +✓ Patch 077e4bbe9a6e5546f400ef5951768c37a76f13a4 opened +To rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi + * [new reference] HEAD -> refs/patches ``` It will now be listed as one of the project's open patches. @@ -80,7 +74,7 @@ index 0000000..e69de29 We can also see that it set an upstream for our patch branch: ``` $ git branch -vv -* flux-capacitor-power 3e674d1 [rad/flux-capacitor-power] Define power requirements +* flux-capacitor-power 3e674d1 [rad/patches/077e4bbe9a6e5546f400ef5951768c37a76f13a4] Define power requirements master f2de534 [rad/master] Second commit ``` diff --git a/radicle-cli/examples/rad-remote.md b/radicle-cli/examples/rad-remote.md index a7a57821..3dce99c9 100644 --- a/radicle-cli/examples/rad-remote.md +++ b/radicle-cli/examples/rad-remote.md @@ -9,10 +9,9 @@ Now, we can see that there is a new remote in the list of remotes: ``` $ rad remote list -bob z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk (fetch) -rad (canonical upstream) (fetch) -rad z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi (push) -rad/patches (patches upstream) (push) +bob z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk (fetch) +rad (canonical upstream) (fetch) +rad z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi (push) ``` You can see both `bob` and `rad` as remotes. The `rad` remote is our personal remote of the project. diff --git a/radicle-cli/examples/workflow/4-patching-contributor.md b/radicle-cli/examples/workflow/4-patching-contributor.md index 92d452db..d22b4aea 100644 --- a/radicle-cli/examples/workflow/4-patching-contributor.md +++ b/radicle-cli/examples/workflow/4-patching-contributor.md @@ -24,17 +24,11 @@ $ git commit -v -m "Define power requirements" Once the code is ready, we open a patch with our changes. -``` -$ rad patch open --message "Define power requirements" --message "See details." -master <- z6Mkt67…v4N1tRk/flux-capacitor-power (3e674d1) -1 commit(s) ahead, 0 commit(s) behind - -3e674d1 Define power requirements - -✓ Patch 50e29a111972f3b7d2123c5057de5bdf09bc7b1c created - -To publish your patch to the network, run: - git push rad +``` (stderr) +$ git push rad -o no-sync -o patch.message="Define power requirements" -o patch.message="See details." HEAD:refs/patches +✓ Patch 50e29a111972f3b7d2123c5057de5bdf09bc7b1c opened +To rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk + * [new reference] HEAD -> refs/patches ``` It will now be listed as one of the project's open patches. @@ -67,8 +61,8 @@ $ rad patch show 50e29a111972f3b7d2123c5057de5bdf09bc7b1c We can also confirm that the patch branch is in storage: ``` -$ git ls-remote rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk refs/heads/flux-capacitor-power -3e674d1a1df90807e934f9ae5da2591dd6848a33 refs/heads/flux-capacitor-power +$ git ls-remote rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk refs/heads/patches/* +3e674d1a1df90807e934f9ae5da2591dd6848a33 refs/heads/patches/50e29a111972f3b7d2123c5057de5bdf09bc7b1c ``` Wait, let's add a README too! Just for fun. @@ -80,10 +74,12 @@ $ 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 -$ rad patch update --message "Add README, just for the fun" 50e29a111972f3b7d2123c5057de5bdf09bc7b1c -Updating 3e674d1 -> 27857ec -1 commit(s) ahead, 0 commit(s) behind -✓ Patch updated to revision 3530243d46a2e7a8e4eac7afcbb17cc7c56b3d29 +``` +``` (stderr) RAD_SOCKET=/dev/null +$ git push -o patch.message="Add README, just for the fun" +✓ Patch 50e29a1 updated to 3530243d46a2e7a8e4eac7afcbb17cc7c56b3d29 +To rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk + 3e674d1..27857ec flux-capacitor-power -> patches/50e29a111972f3b7d2123c5057de5bdf09bc7b1c ``` And let's leave a quick comment for our team: diff --git a/radicle-cli/examples/workflow/5-patching-maintainer.md b/radicle-cli/examples/workflow/5-patching-maintainer.md index 72f0b951..120ba864 100644 --- a/radicle-cli/examples/workflow/5-patching-maintainer.md +++ b/radicle-cli/examples/workflow/5-patching-maintainer.md @@ -21,16 +21,16 @@ $ rad remote add z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk --name bob ``` (stderr) $ git fetch bob From rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk - * [new branch] flux-capacitor-power -> bob/flux-capacitor-power - * [new branch] master -> bob/master + * [new branch] master -> bob/master + * [new branch] patches/50e29a111972f3b7d2123c5057de5bdf09bc7b1c -> bob/patches/50e29a111972f3b7d2123c5057de5bdf09bc7b1c ``` The contributor's changes are now visible to us. ``` $ git branch -r - bob/flux-capacitor-power bob/master + bob/patches/50e29a111972f3b7d2123c5057de5bdf09bc7b1c rad/master $ rad patch show 50e29a1 ╭──────────────────────────────────────────────────────────────────────────────╮ @@ -57,11 +57,11 @@ way will tell others about the corrections we needed before merging the changes. ``` -$ git checkout flux-capacitor-power -branch 'flux-capacitor-power' set up to track 'bob/flux-capacitor-power'. +$ git checkout patches/50e29a111972f3b7d2123c5057de5bdf09bc7b1c +branch 'patches/50e29a111972f3b7d2123c5057de5bdf09bc7b1c' set up to track 'bob/patches/50e29a111972f3b7d2123c5057de5bdf09bc7b1c'. $ git mv REQUIREMENTS REQUIREMENTS.md $ git commit --fixup HEAD~ -[flux-capacitor-power f6484e0] fixup! Define power requirements +[patches/50e29a111972f3b7d2123c5057de5bdf09bc7b1c f6484e0] fixup! Define power requirements 1 file changed, 0 insertions(+), 0 deletions(-) rename REQUIREMENTS => REQUIREMENTS.md (100%) $ rad patch update --message "Define power requirements" --message "See details." 50e29a111972f3b7d2123c5057de5bdf09bc7b1c @@ -75,7 +75,7 @@ Great, all fixed up, lets merge the code. ``` $ git checkout master Your branch is up to date with 'rad/master'. -$ git merge flux-capacitor-power +$ git merge patches/50e29a111972f3b7d2123c5057de5bdf09bc7b1c Updating f2de534..f6484e0 Fast-forward README.md | 0 @@ -95,7 +95,7 @@ $ rad patch show 50e29a1 │ Patch 50e29a111972f3b7d2123c5057de5bdf09bc7b1c │ │ Author did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk │ │ Head f6484e0f43e48a8983b9b39bf9bd4cd889f1d520 │ -│ Branches flux-capacitor-power, master │ +│ Branches master, patches/50e29a111972f3b7d2123c5057de5bdf09bc7b1c │ │ Commits up to date │ │ Status merged │ │ │ diff --git a/radicle-cli/src/commands/clone.rs b/radicle-cli/src/commands/clone.rs index 92d837c9..df819c09 100644 --- a/radicle-cli/src/commands/clone.rs +++ b/radicle-cli/src/commands/clone.rs @@ -117,7 +117,8 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> { let default_branch = proj.default_branch().clone(); let path = working.workdir().unwrap(); // SAFETY: The working copy is not bare. - // Setup tracking for project delegates. + // Configure repository and setup tracking for project delegates. + radicle::git::configure_repository(&working)?; checkout::setup_remotes( project::SetupRemote { project: options.id, diff --git a/radicle-cli/src/commands/patch.rs b/radicle-cli/src/commands/patch.rs index 9ddf40e3..74fc1536 100644 --- a/radicle-cli/src/commands/patch.rs +++ b/radicle-cli/src/commands/patch.rs @@ -4,8 +4,6 @@ mod archive; mod checkout; #[path = "patch/common.rs"] mod common; -#[path = "patch/create.rs"] -mod create; #[path = "patch/delete.rs"] mod delete; #[path = "patch/edit.rs"] @@ -46,7 +44,6 @@ Usage rad patch [