remote-helper: Do not assume remote name

Avoid ending up with an upstream to a potentially non-existent remote
when pushing to an anonymous remote.
This commit is contained in:
Lorenz Leutgeb 2025-09-13 11:51:29 +02:00 committed by Fintan Halpenny
parent 6b9ff4f99e
commit ee9e6de5f3
2 changed files with 16 additions and 16 deletions

View File

@ -187,9 +187,6 @@ pub fn run(profile: radicle::Profile) -> Result<(), Error> {
} }
}; };
// Assume the default remote if there was no remote.
let remote = remote.unwrap_or_else(|| (*radicle::rad::REMOTE_NAME).clone());
let stored = profile.storage.repository_mut(url.repo)?; let stored = profile.storage.repository_mut(url.repo)?;
if stored.is_empty()? { if stored.is_empty()? {
return Err(Error::RepositoryNotFound(stored.path().to_path_buf())); return Err(Error::RepositoryNotFound(stored.path().to_path_buf()));

View File

@ -246,7 +246,7 @@ impl PushAction {
/// Run a git push command. /// Run a git push command.
pub fn run( pub fn run(
mut specs: Vec<String>, mut specs: Vec<String>,
remote: git::RefString, remote: Option<git::RefString>,
url: Url, url: Url,
stored: &storage::git::Repository, stored: &storage::git::Repository,
profile: &Profile, profile: &Profile,
@ -477,7 +477,7 @@ pub fn run(
/// Open a new patch. /// Open a new patch.
fn patch_open<G>( fn patch_open<G>(
src: &git::Oid, src: &git::Oid,
upstream: &git::RefString, upstream: &Option<git::RefString>,
nid: &NodeId, nid: &NodeId,
working: &git::raw::Repository, working: &git::raw::Repository,
stored: &storage::git::Repository, stored: &storage::git::Repository,
@ -564,8 +564,10 @@ where
"Create reference for patch head", "Create reference for patch head",
)?; )?;
if let Some(upstream) = upstream {
// Setup current branch so that pushing updates the patch. // Setup current branch so that pushing updates the patch.
if let Some(branch) = rad::setup_patch_upstream(&patch, head, working, upstream, false)? if let Some(branch) =
rad::setup_patch_upstream(&patch, head, working, upstream, false)?
{ {
if let Some(name) = branch.name()? { if let Some(name) = branch.name()? {
if profile.hints() { if profile.hints() {
@ -578,6 +580,7 @@ where
} }
} }
} }
}
Ok(Some(ExplorerResource::Patch { id: patch })) Ok(Some(ExplorerResource::Patch { id: patch }))
} }
Err(e) => Err(e), Err(e) => Err(e),