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:
parent
6b9ff4f99e
commit
ee9e6de5f3
|
|
@ -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()));
|
||||||
|
|
|
||||||
|
|
@ -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,17 +564,20 @@ where
|
||||||
"Create reference for patch head",
|
"Create reference for patch head",
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
// Setup current branch so that pushing updates the patch.
|
if let Some(upstream) = upstream {
|
||||||
if let Some(branch) = rad::setup_patch_upstream(&patch, head, working, upstream, false)?
|
// Setup current branch so that pushing updates the patch.
|
||||||
{
|
if let Some(branch) =
|
||||||
if let Some(name) = branch.name()? {
|
rad::setup_patch_upstream(&patch, head, working, upstream, false)?
|
||||||
if profile.hints() {
|
{
|
||||||
// Remove the remote portion of the name, i.e.
|
if let Some(name) = branch.name()? {
|
||||||
// rad/patches/deadbeef -> patches/deadbeef
|
if profile.hints() {
|
||||||
let name = name.split('/').skip(1).collect::<Vec<_>>().join("/");
|
// Remove the remote portion of the name, i.e.
|
||||||
hint(format!(
|
// rad/patches/deadbeef -> patches/deadbeef
|
||||||
"to update, run `git push` or `git push rad -f HEAD:{name}`"
|
let name = name.split('/').skip(1).collect::<Vec<_>>().join("/");
|
||||||
));
|
hint(format!(
|
||||||
|
"to update, run `git push` or `git push rad -f HEAD:{name}`"
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue