radicle: custom upstream remote for patches

When creating a new upstream for the patch workflow, the remote name is always
assumed to be `rad`.

It's possible for users to use another remote name but still use a `rad://` URL
for pushing. To allow for this, the function that creates the upstream entry now
takes a remote name. In the remote helper, `rad patch checkout`, and `rad patch
set` the remote can be optionally specified and fall back to the `rad` remote
name as a default.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
This commit is contained in:
Fintan Halpenny
2024-09-12 17:59:57 +02:00
committed by cloudhead
parent 00639182a7
commit e130b4dc06
5 changed files with 48 additions and 14 deletions
+8 -1
View File
@@ -14,6 +14,7 @@ use crate::terminal as term;
#[derive(Debug, Default)]
pub struct Options {
pub name: Option<RefString>,
pub remote: Option<RefString>,
pub force: bool,
}
@@ -97,7 +98,13 @@ pub fn run(
));
spinner.finish();
if let Some(branch) = rad::setup_patch_upstream(patch_id, revision.head(), working, false)? {
if let Some(branch) = rad::setup_patch_upstream(
patch_id,
revision.head(),
working,
opts.remote.as_ref().unwrap_or(&radicle::rad::REMOTE_NAME),
false,
)? {
let tracking = branch
.name()?
.ok_or_else(|| anyhow!("failed to create tracking branch: invalid name"))?;