diff --git a/radicle-cli/examples/rad-patch-via-push.md b/radicle-cli/examples/rad-patch-via-push.md index 53e05e49..d4e9d256 100644 --- a/radicle-cli/examples/rad-patch-via-push.md +++ b/radicle-cli/examples/rad-patch-via-push.md @@ -3,12 +3,16 @@ Let's checkout a branch, make a commit and push to the magic ref `refs/patches`. When we push to this ref, a patch is created from our commits. -``` (stderr) +``` (stderr) RAD_HINT=1 $ git checkout -b feature/1 Switched to a new branch 'feature/1' $ git commit -a -m "Add things" -q --allow-empty $ git push -o patch.message="Add things #1" -o patch.message="See commits for details." rad HEAD:refs/patches ✓ Patch 82faae29b2a2f11bf45bbba4c4787d6b32a12447 opened +hint: to update, run `git push`, + or `git push rad -f HEAD:rad/patches/82faae29b2a2f11bf45bbba4c4787d6b32a12447` +hint: offline push, your node is not running + to sync with the network, run `rad node start` To rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi * [new reference] HEAD -> refs/patches ``` diff --git a/radicle-remote-helper/src/push.rs b/radicle-remote-helper/src/push.rs index 813c7b1b..f43963ad 100644 --- a/radicle-remote-helper/src/push.rs +++ b/radicle-remote-helper/src/push.rs @@ -203,7 +203,7 @@ pub fn run( let working = git::raw::Repository::open(working)?; if dst == &*rad::PATCHES_REFNAME { - patch_open(src, &nid, &working, stored, &signer, opts.clone()) + patch_open(src, &nid, &working, stored, &signer, profile, opts.clone()) } else { let dst = git::Qualified::from_refstr(dst) .ok_or_else(|| Error::InvalidQualifiedRef(dst.clone()))?; @@ -288,7 +288,7 @@ pub fn run( sync(stored.id, node).ok(); } else if hints { eprintln!("hint: offline push, your node is not running"); - eprintln!("hint: to sync with the network, run `rad node start`"); + eprintln!(" to sync with the network, run `rad node start`"); } } } @@ -306,6 +306,7 @@ fn patch_open( working: &git::raw::Repository, stored: &storage::git::Repository, signer: &G, + profile: &Profile, opts: Options, ) -> Result<(), Error> { let reference = working.find_reference(src.as_str())?; @@ -384,7 +385,16 @@ fn patch_open( )?; // Setup current branch so that pushing updates the patch. - rad::setup_patch_upstream(&patch, commit.id().into(), working, false)?; + if let Some(branch) = + rad::setup_patch_upstream(&patch, commit.id().into(), working, false)? + { + if let Some(name) = branch.name()? { + if profile.hints() { + eprintln!("hint: to update, run `git push`,"); + eprintln!(" or `git push rad -f HEAD:{name}`"); + } + } + } Ok(()) }