mirror of
https://seed.radicle.dev/rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5.git
synced 2026-11-16 08:10:40 +08:00
cli: Use git push to open or update patches
This adds the ability to the git-remote-helper to open and update patches via a `git push` to the magic ref `refs/patches` and `refs/heads/patches/<patch-id>`. The main change is that we had to move away from offering the `connect` capability in the remote helper, to offering `push` and `fetch` individually. To get a feel for how this works, see the `rad-patch-via-push.md` example.
This commit is contained in:
@@ -239,9 +239,9 @@ pub fn init(options: Options, profile: &profile::Profile) -> anyhow::Result<()>
|
||||
// Setup eg. `master` -> `rad/master`
|
||||
radicle::git::set_upstream(
|
||||
&repo,
|
||||
&radicle::rad::REMOTE_NAME,
|
||||
&*radicle::rad::REMOTE_NAME,
|
||||
proj.default_branch(),
|
||||
&radicle::git::refs::workdir::branch(proj.default_branch()),
|
||||
radicle::git::refs::workdir::branch(proj.default_branch()),
|
||||
)?;
|
||||
} else {
|
||||
push_cmd = format!("git push {}", *radicle::rad::REMOTE_NAME);
|
||||
|
||||
@@ -60,11 +60,12 @@ pub fn run(
|
||||
let (target_ref, target_oid) = get_merge_target(storage, &head_branch)?;
|
||||
|
||||
if head_branch.upstream().is_err() {
|
||||
// TODO(cloudhead): Disable this when invoked from remote helper.
|
||||
radicle::git::set_upstream(
|
||||
workdir,
|
||||
&radicle::rad::REMOTE_NAME,
|
||||
&*radicle::rad::REMOTE_NAME,
|
||||
branch_name(&head_branch)?,
|
||||
&head_branch_name,
|
||||
head_branch_name,
|
||||
)?;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use radicle::rad;
|
||||
use radicle_term::{Element, Table};
|
||||
|
||||
use crate::git;
|
||||
@@ -11,13 +12,22 @@ pub fn run(repo: &git::Repository) -> anyhow::Result<()> {
|
||||
let Some(url) = url else {
|
||||
continue;
|
||||
};
|
||||
let nid = url.namespace.map_or(
|
||||
term::format::dim("the canonical upstream".to_string()).italic(),
|
||||
|namespace| term::format::tertiary(namespace.to_string()),
|
||||
);
|
||||
|
||||
let description = if r.name == rad::PATCHES_REMOTE_NAME.as_str() {
|
||||
if dir == "fetch" {
|
||||
// Fetching from the patches remote is not allowed.
|
||||
continue;
|
||||
}
|
||||
term::format::dim("(patches upstream)".to_string()).italic()
|
||||
} else {
|
||||
url.namespace.map_or(
|
||||
term::format::dim("(canonical upstream)".to_string()).italic(),
|
||||
|namespace| term::format::tertiary(namespace.to_string()),
|
||||
)
|
||||
};
|
||||
table.push([
|
||||
term::format::bold(r.name.clone()),
|
||||
nid,
|
||||
description,
|
||||
term::format::parens(term::format::secondary(dir.to_owned())),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ fn announce(rid: Id, mut node: Node, timeout: time::Duration) -> anyhow::Result<
|
||||
let mut seeds = seeds.connected().collect::<BTreeSet<_>>();
|
||||
|
||||
if seeds.is_empty() {
|
||||
term::info!("Not connected to any seeds");
|
||||
term::info!("Not connected to any seeds.");
|
||||
return Ok(());
|
||||
}
|
||||
node.announce_refs(rid)?;
|
||||
|
||||
@@ -37,7 +37,7 @@ impl<'a> SetupRemote<'a> {
|
||||
let local_branch = radicle::git::refs::workdir::branch(
|
||||
node_ref.join(&self.default_branch).as_refstr(),
|
||||
);
|
||||
radicle::git::set_upstream(self.repo, &node.to_string(), &branch_name, &local_branch)?;
|
||||
radicle::git::set_upstream(self.repo, node.to_string(), &branch_name, local_branch)?;
|
||||
|
||||
return Ok(Some((remote, branch_name)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user