chore: Automated fixes generated by clippy
This commit is contained in:
parent
586eefc3e4
commit
9068033789
|
|
@ -171,8 +171,7 @@ pub fn authenticate(options: Options, profile: &Profile) -> anyhow::Result<()> {
|
||||||
}
|
}
|
||||||
for (key, _) in &profile.config.node.extra {
|
for (key, _) in &profile.config.node.extra {
|
||||||
term::warning(format!(
|
term::warning(format!(
|
||||||
"unused or deprecated configuration attribute {:?}",
|
"unused or deprecated configuration attribute {key:?}"
|
||||||
key
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -397,7 +397,7 @@ pub fn run(Options { op }: Options, ctx: impl term::Context) -> anyhow::Result<(
|
||||||
oid
|
oid
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
println!("{}", oid);
|
println!("{oid}");
|
||||||
}
|
}
|
||||||
Migrate => {
|
Migrate => {
|
||||||
let mut db = profile.cobs_db_mut()?;
|
let mut db = profile.cobs_db_mut()?;
|
||||||
|
|
@ -501,7 +501,7 @@ pub fn run(Options { op }: Options, ctx: impl term::Context) -> anyhow::Result<(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
println!("{}", oid);
|
println!("{oid}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -588,13 +588,13 @@ fn print_op_pretty(op: cob::Op<Vec<u8>>) -> anyhow::Result<()> {
|
||||||
term::print(term::format::tertiary(format!("resource {oid}")));
|
term::print(term::format::tertiary(format!("resource {oid}")));
|
||||||
}
|
}
|
||||||
for parent in op.parents {
|
for parent in op.parents {
|
||||||
term::print(format!("parent {}", parent));
|
term::print(format!("parent {parent}"));
|
||||||
}
|
}
|
||||||
for parent in op.related {
|
for parent in op.related {
|
||||||
term::print(format!("rel {}", parent));
|
term::print(format!("rel {parent}"));
|
||||||
}
|
}
|
||||||
term::print(format!("author {}", op.author));
|
term::print(format!("author {}", op.author));
|
||||||
term::print(format!("date {}", time));
|
term::print(format!("date {time}"));
|
||||||
term::blank();
|
term::blank();
|
||||||
for action in op.actions {
|
for action in op.actions {
|
||||||
let obj: serde_json::Value = serde_json::from_slice(&action)?;
|
let obj: serde_json::Value = serde_json::from_slice(&action)?;
|
||||||
|
|
|
||||||
|
|
@ -68,11 +68,7 @@ fn debug(profile: Option<&Profile>) -> anyhow::Result<()> {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
let debug = DebugInfo {
|
let debug = DebugInfo {
|
||||||
rad_exe: if let Ok(filename) = std::env::current_exe() {
|
rad_exe: std::env::current_exe().ok(),
|
||||||
Some(filename)
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
},
|
|
||||||
rad_version: VERSION,
|
rad_version: VERSION,
|
||||||
radicle_node_version: stdout_of("radicle-node", &["--version"])
|
radicle_node_version: stdout_of("radicle-node", &["--version"])
|
||||||
.unwrap_or("<unknown>".into()),
|
.unwrap_or("<unknown>".into()),
|
||||||
|
|
|
||||||
|
|
@ -396,8 +396,7 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
|
||||||
Err(errs) => {
|
Err(errs) => {
|
||||||
term::error(format!("failed to verify delegates for {rid}"));
|
term::error(format!("failed to verify delegates for {rid}"));
|
||||||
term::error(format!(
|
term::error(format!(
|
||||||
"the threshold of {} delegates cannot be met..",
|
"the threshold of {threshold} delegates cannot be met.."
|
||||||
threshold
|
|
||||||
));
|
));
|
||||||
for e in errs {
|
for e in errs {
|
||||||
print_delegate_verification_error(&e);
|
print_delegate_verification_error(&e);
|
||||||
|
|
|
||||||
|
|
@ -582,7 +582,7 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
|
||||||
})?
|
})?
|
||||||
.context("No issue with the given ID exists")?;
|
.context("No issue with the given ID exists")?;
|
||||||
if debug {
|
if debug {
|
||||||
println!("{:#?}", issue);
|
println!("{issue:#?}");
|
||||||
} else {
|
} else {
|
||||||
term::issue::show(&issue, &id, format, &profile)?;
|
term::issue::show(&issue, &id, format, &profile)?;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -140,7 +140,7 @@ pub fn row(
|
||||||
Ok([
|
Ok([
|
||||||
match state {
|
match state {
|
||||||
patch::State::Open { .. } => term::format::positive("●").into(),
|
patch::State::Open { .. } => term::format::positive("●").into(),
|
||||||
patch::State::Archived { .. } => term::format::yellow("●").into(),
|
patch::State::Archived => term::format::yellow("●").into(),
|
||||||
patch::State::Draft => term::format::dim("●").into(),
|
patch::State::Draft => term::format::dim("●").into(),
|
||||||
patch::State::Merged { .. } => term::format::primary("✔").into(),
|
patch::State::Merged { .. } => term::format::primary("✔").into(),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ use super::*;
|
||||||
|
|
||||||
fn show_patch_diff(patch: &patch::Patch, stored: &Repository) -> anyhow::Result<()> {
|
fn show_patch_diff(patch: &patch::Patch, stored: &Repository) -> anyhow::Result<()> {
|
||||||
let (from, to) = patch.range()?;
|
let (from, to) = patch.range()?;
|
||||||
let range = format!("{}..{}", from, to);
|
let range = format!("{from}..{to}");
|
||||||
|
|
||||||
process::Command::new("git")
|
process::Command::new("git")
|
||||||
.current_dir(stored.path())
|
.current_dir(stored.path())
|
||||||
|
|
@ -42,7 +42,7 @@ pub fn run(
|
||||||
};
|
};
|
||||||
|
|
||||||
if debug {
|
if debug {
|
||||||
println!("{:#?}", patch);
|
println!("{patch:#?}");
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
term::patch::show(&patch, patch_id, verbose, stored, workdir, profile)?;
|
term::patch::show(&patch, patch_id, verbose, stored, workdir, profile)?;
|
||||||
|
|
|
||||||
|
|
@ -741,7 +741,7 @@ impl FetcherSpinner {
|
||||||
required
|
required
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
message.push_str(&format!("required {} more seed(s)", required));
|
message.push_str(&format!("required {required} more seed(s)"));
|
||||||
}
|
}
|
||||||
self.spinner.message(message);
|
self.spinner.message(message);
|
||||||
self.spinner.failed();
|
self.spinner.failed();
|
||||||
|
|
|
||||||
|
|
@ -388,10 +388,7 @@ pub fn commit_ssh_fingerprint(path: &Path, sha1: &str) -> Result<Option<String>,
|
||||||
.output()?;
|
.output()?;
|
||||||
|
|
||||||
if !output.status.success() {
|
if !output.status.success() {
|
||||||
return Err(io::Error::new(
|
return Err(io::Error::other(String::from_utf8_lossy(&output.stderr)));
|
||||||
io::ErrorKind::Other,
|
|
||||||
String::from_utf8_lossy(&output.stderr),
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let string = BufReader::new(output.stdout.as_slice())
|
let string = BufReader::new(output.stdout.as_slice())
|
||||||
|
|
|
||||||
|
|
@ -304,8 +304,7 @@ impl unified_diff::Decode for DiffModification {
|
||||||
},
|
},
|
||||||
(v1, v2) => {
|
(v1, v2) => {
|
||||||
return Err(unified_diff::Error::syntax(format!(
|
return Err(unified_diff::Error::syntax(format!(
|
||||||
"indicator character expected, but got '{0}{1}'",
|
"indicator character expected, but got '{v1}{v2}'"
|
||||||
v1, v2
|
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -202,9 +202,9 @@ impl Decode for Diff {
|
||||||
r.read_to_string(&mut s)?;
|
r.read_to_string(&mut s)?;
|
||||||
|
|
||||||
let d = git::raw::Diff::from_buffer(s.as_ref())
|
let d = git::raw::Diff::from_buffer(s.as_ref())
|
||||||
.map_err(|e| Error::syntax(format!("decoding unified diff: {}", e)))?;
|
.map_err(|e| Error::syntax(format!("decoding unified diff: {e}")))?;
|
||||||
let d = Diff::try_from(d)
|
let d =
|
||||||
.map_err(|e| Error::syntax(format!("decoding unified diff: {}", e)))?;
|
Diff::try_from(d).map_err(|e| Error::syntax(format!("decoding unified diff: {e}")))?;
|
||||||
|
|
||||||
Ok(d)
|
Ok(d)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -350,7 +350,7 @@ pub mod patch {
|
||||||
/// Format patch state.
|
/// Format patch state.
|
||||||
pub fn state(s: &State) -> term::Paint<String> {
|
pub fn state(s: &State) -> term::Paint<String> {
|
||||||
match s {
|
match s {
|
||||||
State::Draft { .. } => term::format::dim(s.to_string()),
|
State::Draft => term::format::dim(s.to_string()),
|
||||||
State::Open { .. } => term::format::positive(s.to_string()),
|
State::Open { .. } => term::format::positive(s.to_string()),
|
||||||
State::Archived => term::format::yellow(s.to_string()),
|
State::Archived => term::format::yellow(s.to_string()),
|
||||||
State::Merged { .. } => term::format::secondary(s.to_string()),
|
State::Merged { .. } => term::format::secondary(s.to_string()),
|
||||||
|
|
@ -366,10 +366,10 @@ pub mod identity {
|
||||||
/// Format identity revision state.
|
/// Format identity revision state.
|
||||||
pub fn state(s: &State) -> term::Paint<String> {
|
pub fn state(s: &State) -> term::Paint<String> {
|
||||||
match s {
|
match s {
|
||||||
State::Active { .. } => term::format::tertiary(s.to_string()),
|
State::Active => term::format::tertiary(s.to_string()),
|
||||||
State::Accepted { .. } => term::format::positive(s.to_string()),
|
State::Accepted => term::format::positive(s.to_string()),
|
||||||
State::Rejected { .. } => term::format::negative(s.to_string()),
|
State::Rejected => term::format::negative(s.to_string()),
|
||||||
State::Stale { .. } => term::format::dim(s.to_string()),
|
State::Stale => term::format::dim(s.to_string()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -241,7 +241,7 @@ pub fn get_create_message(
|
||||||
|
|
||||||
/// The message shown in the editor when editing a `Patch`.
|
/// The message shown in the editor when editing a `Patch`.
|
||||||
fn edit_display_message(title: &str, description: &str) -> String {
|
fn edit_display_message(title: &str, description: &str) -> String {
|
||||||
format!("{}\n\n{}\n{PATCH_MSG}", title, description)
|
format!("{title}\n\n{description}\n{PATCH_MSG}")
|
||||||
.trim_start()
|
.trim_start()
|
||||||
.to_string()
|
.to_string()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,7 @@ fn nodes_renamed_for_option(
|
||||||
let old: Address = value.into();
|
let old: Address = value.into();
|
||||||
if let Some(new) = NODES_RENAMED.get(&old) {
|
if let Some(new) = NODES_RENAMED.get(&old) {
|
||||||
warnings.push(format!(
|
warnings.push(format!(
|
||||||
"Value of configuration option `{option}` at index {i} mentions node with address '{}', which has been renamed to '{}'. Please update your configuration.",
|
"Value of configuration option `{option}` at index {i} mentions node with address '{old}', which has been renamed to '{new}'. Please update your configuration."
|
||||||
old, new
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,7 @@ fn rad_cob_multiset() {
|
||||||
log::warn!(target: "test", "`jq` not found. Succeeding prematurely.");
|
log::warn!(target: "test", "`jq` not found. Succeeding prematurely.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Err(e) => panic!("while checking for jq: {}", e),
|
Err(e) => panic!("while checking for jq: {e}"),
|
||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1713,7 +1713,7 @@ fn test_cob_deletion() {
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let issue_id = issue.id();
|
let issue_id = issue.id();
|
||||||
log::debug!(target: "test", "Issue {} created", issue_id);
|
log::debug!(target: "test", "Issue {issue_id} created");
|
||||||
|
|
||||||
bob.rad("clone", &[rid.to_string().as_str()], working.path())
|
bob.rad("clone", &[rid.to_string().as_str()], working.path())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
|
||||||
|
|
@ -312,7 +312,7 @@ fn copy_to(
|
||||||
object: ObjectId,
|
object: ObjectId,
|
||||||
) -> Result<(), git2::Error> {
|
) -> Result<(), git2::Error> {
|
||||||
let original = {
|
let original = {
|
||||||
let name = format!("refs/rad/{}/cobs/{}/{}", from, typename, object);
|
let name = format!("refs/rad/{from}/cobs/{typename}/{object}");
|
||||||
let r = repo.find_reference(&name)?;
|
let r = repo.find_reference(&name)?;
|
||||||
r.target().unwrap()
|
r.target().unwrap()
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -233,7 +233,7 @@ impl FetchState {
|
||||||
.collect::<Vec<_>>(),
|
.collect::<Vec<_>>(),
|
||||||
None => vec![],
|
None => vec![],
|
||||||
};
|
};
|
||||||
log::trace!(target: "fetch", "Received refs {:?}", refs);
|
log::trace!(target: "fetch", "Received refs {refs:?}");
|
||||||
step.pre_validate(&refs)?;
|
step.pre_validate(&refs)?;
|
||||||
|
|
||||||
let wants_haves = step.wants_haves(&handle.repo, &refs)?;
|
let wants_haves = step.wants_haves(&handle.repo, &refs)?;
|
||||||
|
|
@ -318,7 +318,7 @@ impl FetchState {
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
let followed = handle.allowed();
|
let followed = handle.allowed();
|
||||||
log::trace!(target: "fetch", "Followed nodes {:?}", followed);
|
log::trace!(target: "fetch", "Followed nodes {followed:?}");
|
||||||
let special_refs = stage::SpecialRefs {
|
let special_refs = stage::SpecialRefs {
|
||||||
blocked: handle.blocked.clone(),
|
blocked: handle.blocked.clone(),
|
||||||
remote,
|
remote,
|
||||||
|
|
|
||||||
|
|
@ -252,7 +252,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
fn io_other(err: impl std::error::Error + Send + Sync + 'static) -> io::Error {
|
fn io_other(err: impl std::error::Error + Send + Sync + 'static) -> io::Error {
|
||||||
io::Error::new(io::ErrorKind::Other, err)
|
io::Error::other(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
|
|
|
||||||
|
|
@ -46,8 +46,7 @@ where
|
||||||
} = handshake;
|
} = handshake;
|
||||||
|
|
||||||
if protocol != &Protocol::V2 {
|
if protocol != &Protocol::V2 {
|
||||||
return Err(ls_refs::Error::Io(io::Error::new(
|
return Err(ls_refs::Error::Io(io::Error::other(
|
||||||
io::ErrorKind::Other,
|
|
||||||
"expected protocol version 2",
|
"expected protocol version 2",
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ where
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Err(e) => log::error!(target: "control", "Failed to accept incoming connection: {}", e),
|
Err(e) => log::error!(target: "control", "Failed to accept incoming connection: {e}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log::debug!(target: "control", "Exiting control loop..");
|
log::debug!(target: "control", "Exiting control loop..");
|
||||||
|
|
|
||||||
|
|
@ -138,7 +138,7 @@ impl Runtime {
|
||||||
let policy = config.seeding_policy.into();
|
let policy = config.seeding_policy.into();
|
||||||
|
|
||||||
for (key, _) in &config.extra {
|
for (key, _) in &config.extra {
|
||||||
log::warn!(target: "node", "Unused or deprecated configuration attribute {:?}", key);
|
log::warn!(target: "node", "Unused or deprecated configuration attribute {key:?}");
|
||||||
}
|
}
|
||||||
|
|
||||||
log::info!(target: "node", "Opening policy database..");
|
log::info!(target: "node", "Opening policy database..");
|
||||||
|
|
@ -158,7 +158,7 @@ impl Runtime {
|
||||||
}
|
}
|
||||||
|
|
||||||
log::info!(target: "node", "Default seeding policy set to '{}'", &policy);
|
log::info!(target: "node", "Default seeding policy set to '{}'", &policy);
|
||||||
log::info!(target: "node", "Initializing service ({:?})..", network);
|
log::info!(target: "node", "Initializing service ({network:?})..");
|
||||||
|
|
||||||
let announcement = if let Some(ann) = fs::read(node_dir.join(node::NODE_ANNOUNCEMENT_FILE))
|
let announcement = if let Some(ann) = fs::read(node_dir.join(node::NODE_ANNOUNCEMENT_FILE))
|
||||||
.ok()
|
.ok()
|
||||||
|
|
|
||||||
|
|
@ -275,8 +275,8 @@ impl radicle::node::Handle for Handle {
|
||||||
let query: Arc<QueryState> = Arc::new(move |state| {
|
let query: Arc<QueryState> = Arc::new(move |state| {
|
||||||
let sessions = state
|
let sessions = state
|
||||||
.sessions()
|
.sessions()
|
||||||
.iter()
|
.values()
|
||||||
.map(|(_, s)| radicle::node::Session::from(s))
|
.map(radicle::node::Session::from)
|
||||||
.collect();
|
.collect();
|
||||||
sender.send(sessions).ok();
|
sender.send(sessions).ok();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -360,7 +360,7 @@ where
|
||||||
if let Some((time, next)) = priority.or_else(|| self.inbox.next()) {
|
if let Some((time, next)) = priority.or_else(|| self.inbox.next()) {
|
||||||
let elapsed = (time - self.start_time).as_millis();
|
let elapsed = (time - self.start_time).as_millis();
|
||||||
if matches!(next.input, Input::Wake) {
|
if matches!(next.input, Input::Wake) {
|
||||||
trace!(target: "sim", "{:05} {}", elapsed, next);
|
trace!(target: "sim", "{elapsed:05} {next}");
|
||||||
} else {
|
} else {
|
||||||
// TODO: This can be confusing, since this event may not actually be passed to
|
// TODO: This can be confusing, since this event may not actually be passed to
|
||||||
// the service. It would be best to only log the events that are being sent
|
// the service. It would be best to only log the events that are being sent
|
||||||
|
|
@ -477,8 +477,7 @@ where
|
||||||
// Drop message if nodes are partitioned.
|
// Drop message if nodes are partitioned.
|
||||||
info!(
|
info!(
|
||||||
target: "sim",
|
target: "sim",
|
||||||
"{} -> {} (DROPPED)",
|
"{sender} -> {receiver} (DROPPED)",
|
||||||
sender, receiver,
|
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -497,8 +496,7 @@ where
|
||||||
for msg in &msgs {
|
for msg in &msgs {
|
||||||
info!(
|
info!(
|
||||||
target: "sim",
|
target: "sim",
|
||||||
"{:05} {} -> {} ({:?}) (+{})",
|
"{elapsed:05} {sender} -> {receiver} ({msg:?}) (+{latency})"
|
||||||
elapsed, sender, receiver, msg, latency
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -528,7 +526,7 @@ where
|
||||||
|
|
||||||
// Fail to connect if the nodes are partitioned.
|
// Fail to connect if the nodes are partitioned.
|
||||||
if self.is_partitioned(node, remote) {
|
if self.is_partitioned(node, remote) {
|
||||||
log::info!(target: "sim", "{} -/-> {} (partitioned)", node, remote);
|
log::info!(target: "sim", "{node} -/-> {remote} (partitioned)");
|
||||||
|
|
||||||
// Sometimes, the service gets a failure input, other times it just hangs.
|
// Sometimes, the service gets a failure input, other times it just hangs.
|
||||||
if self.rng.borrow_mut().bool() {
|
if self.rng.borrow_mut().bool() {
|
||||||
|
|
|
||||||
|
|
@ -918,7 +918,7 @@ fn test_non_fastforward_sigrefs() {
|
||||||
let old_bob = match up {
|
let old_bob = match up {
|
||||||
RefUpdate::Created { oid, .. } => oid,
|
RefUpdate::Created { oid, .. } => oid,
|
||||||
RefUpdate::Skipped { oid, .. } => oid,
|
RefUpdate::Skipped { oid, .. } => oid,
|
||||||
_ => panic!("rad/sigrefs should have been created or skipped: {:?}", up),
|
_ => panic!("rad/sigrefs should have been created or skipped: {up:?}"),
|
||||||
};
|
};
|
||||||
assert_eq!(bob_sigrefs, old_bob);
|
assert_eq!(bob_sigrefs, old_bob);
|
||||||
|
|
||||||
|
|
@ -930,7 +930,7 @@ fn test_non_fastforward_sigrefs() {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.reference_oid(&bob.id, &radicle::storage::refs::SIGREFS_BRANCH)
|
.reference_oid(&bob.id, &radicle::storage::refs::SIGREFS_BRANCH)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
log::debug!(target: "test", "bob's old 'rad/sigrefs': {}", before);
|
log::debug!(target: "test", "bob's old 'rad/sigrefs': {before}");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now Eve disconnects from Bob so she doesn't fetch his update.
|
// Now Eve disconnects from Bob so she doesn't fetch his update.
|
||||||
|
|
@ -961,7 +961,7 @@ fn test_non_fastforward_sigrefs() {
|
||||||
RefUpdate::Updated { new, .. } => new,
|
RefUpdate::Updated { new, .. } => new,
|
||||||
// FIXME: Really it shouldn't be skipped but let's see what happens
|
// FIXME: Really it shouldn't be skipped but let's see what happens
|
||||||
RefUpdate::Skipped { oid, .. } => oid,
|
RefUpdate::Skipped { oid, .. } => oid,
|
||||||
_ => panic!("rad/sigrefs should have been updated {:?}", up),
|
_ => panic!("rad/sigrefs should have been updated {up:?}"),
|
||||||
};
|
};
|
||||||
assert_eq!(bob_sigrefs, new_bob);
|
assert_eq!(bob_sigrefs, new_bob);
|
||||||
|
|
||||||
|
|
@ -973,7 +973,7 @@ fn test_non_fastforward_sigrefs() {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.reference_oid(&bob.id, &radicle::storage::refs::SIGREFS_BRANCH)
|
.reference_oid(&bob.id, &radicle::storage::refs::SIGREFS_BRANCH)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
log::debug!(target: "test", "bob's new 'rad/sigrefs': {}", after);
|
log::debug!(target: "test", "bob's new 'rad/sigrefs': {after}");
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_matches!(
|
assert_matches!(
|
||||||
|
|
@ -1542,7 +1542,6 @@ fn test_channel_reader_limit() {
|
||||||
assert!(
|
assert!(
|
||||||
reason.contains("Failed to consume the pack sent by the remote")
|
reason.contains("Failed to consume the pack sent by the remote")
|
||||||
|| reason.contains("exceeded number of allowed bytes"),
|
|| reason.contains("exceeded number of allowed bytes"),
|
||||||
"actual: {}",
|
"actual: {reason}"
|
||||||
reason
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -959,7 +959,7 @@ where
|
||||||
e.remove();
|
e.remove();
|
||||||
}
|
}
|
||||||
Peer::Connected { nid, .. } => {
|
Peer::Connected { nid, .. } => {
|
||||||
panic!("Wire::handover_transport: Unexpected handover of connected peer {} with id={id} (fd={fd})", nid);
|
panic!("Wire::handover_transport: Unexpected handover of connected peer {nid} with id={id} (fd={fd})");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -171,8 +171,7 @@ impl ReadLimiter {
|
||||||
self.total_read = self.total_read.saturating_add(bytes);
|
self.total_read = self.total_read.saturating_add(bytes);
|
||||||
log::trace!(target: "worker", "limit {}, total bytes read: {}", self.limit, self.total_read);
|
log::trace!(target: "worker", "limit {}, total bytes read: {}", self.limit, self.total_read);
|
||||||
if self.limit.exceeded_by(self.total_read) {
|
if self.limit.exceeded_by(self.total_read) {
|
||||||
Err(io::Error::new(
|
Err(io::Error::other(
|
||||||
io::ErrorKind::Other,
|
|
||||||
"sender has exceeded number of allowed bytes, aborting read",
|
"sender has exceeded number of allowed bytes, aborting read",
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@ impl Handle {
|
||||||
validations,
|
validations,
|
||||||
} => {
|
} => {
|
||||||
for fail in validations.iter() {
|
for fail in validations.iter() {
|
||||||
log::error!(target: "worker", "Validation error: {}", fail);
|
log::error!(target: "worker", "Validation error: {fail}");
|
||||||
}
|
}
|
||||||
Err(error::Fetch::Validation {
|
Err(error::Fetch::Validation {
|
||||||
threshold,
|
threshold,
|
||||||
|
|
@ -109,7 +109,7 @@ impl Handle {
|
||||||
validations,
|
validations,
|
||||||
} => {
|
} => {
|
||||||
for warn in validations {
|
for warn in validations {
|
||||||
log::warn!(target: "worker", "Validation error: {}", warn);
|
log::warn!(target: "worker", "Validation error: {warn}");
|
||||||
}
|
}
|
||||||
|
|
||||||
// N.b. We do not go through handle for this since the cloning handle
|
// N.b. We do not go through handle for this since the cloning handle
|
||||||
|
|
@ -180,7 +180,7 @@ fn mv(tmp: tempfile::TempDir, storage: &Storage, rid: &RepoId) -> Result<(), err
|
||||||
log::warn!(target: "worker", "Refusing to move cloned repository {rid} already exists");
|
log::warn!(target: "worker", "Refusing to move cloned repository {rid} already exists");
|
||||||
return Err(Error::new(
|
return Err(Error::new(
|
||||||
ErrorKind::AlreadyExists,
|
ErrorKind::AlreadyExists,
|
||||||
format!("repository already exists {:?}", to),
|
format!("repository already exists {to:?}"),
|
||||||
)
|
)
|
||||||
.into());
|
.into());
|
||||||
}
|
}
|
||||||
|
|
@ -402,8 +402,7 @@ fn set_canonical_refs(repo: &Repository, applied: &Applied) -> Result<(), error:
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
log::warn!(
|
log::warn!(
|
||||||
target: "worker",
|
target: "worker",
|
||||||
"Failed to calculate canonical reference: {}",
|
"Failed to calculate canonical reference: {err}",
|
||||||
err,
|
|
||||||
);
|
);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -416,9 +415,7 @@ fn set_canonical_refs(repo: &Repository, applied: &Applied) -> Result<(), error:
|
||||||
) {
|
) {
|
||||||
log::warn!(
|
log::warn!(
|
||||||
target: "worker",
|
target: "worker",
|
||||||
"Failed to set canonical reference {}->{}: {e}",
|
"Failed to set canonical reference {refname}->{oid}: {e}"
|
||||||
refname,
|
|
||||||
oid
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -847,7 +847,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn command(&mut self, cmd: Command) {
|
pub fn command(&mut self, cmd: Command) {
|
||||||
info!(target: "service", "Received command {:?}", cmd);
|
info!(target: "service", "Received command {cmd:?}");
|
||||||
|
|
||||||
match cmd {
|
match cmd {
|
||||||
Command::Connect(nid, addr, opts) => {
|
Command::Connect(nid, addr, opts) => {
|
||||||
|
|
@ -1396,7 +1396,7 @@ where
|
||||||
let Some(session) = self.sessions.get_mut(&remote) else {
|
let Some(session) = self.sessions.get_mut(&remote) else {
|
||||||
// Since we sometimes disconnect the service eagerly, it's not unusual to get a second
|
// Since we sometimes disconnect the service eagerly, it's not unusual to get a second
|
||||||
// disconnection event once the transport is dropped.
|
// disconnection event once the transport is dropped.
|
||||||
trace!(target: "service", "Redundant disconnection for {} ({})", remote, reason);
|
trace!(target: "service", "Redundant disconnection for {remote} ({reason})");
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
// In cases of connection conflicts, there may be disconnections of one of the two
|
// In cases of connection conflicts, there may be disconnections of one of the two
|
||||||
|
|
@ -1405,7 +1405,7 @@ where
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
info!(target: "service", "Disconnected from {} ({})", remote, reason);
|
info!(target: "service", "Disconnected from {remote} ({reason})");
|
||||||
self.emitter.emit(Event::PeerDisconnected {
|
self.emitter.emit(Event::PeerDisconnected {
|
||||||
nid: remote,
|
nid: remote,
|
||||||
reason: reason.to_string(),
|
reason: reason.to_string(),
|
||||||
|
|
@ -1836,7 +1836,7 @@ where
|
||||||
//
|
//
|
||||||
// This is not ideal, but until the wire protocol and service are unified, it's the simplest
|
// This is not ideal, but until the wire protocol and service are unified, it's the simplest
|
||||||
// solution to converge towards the same state.
|
// solution to converge towards the same state.
|
||||||
session::State::Attempted { .. } | session::State::Initial => {
|
session::State::Attempted | session::State::Initial => {
|
||||||
debug!(target: "service", "Received unexpected message from connecting peer {}", peer.id);
|
debug!(target: "service", "Received unexpected message from connecting peer {}", peer.id);
|
||||||
debug!(target: "service", "Transitioning peer {} to 'connected' state", peer.id);
|
debug!(target: "service", "Transitioning peer {} to 'connected' state", peer.id);
|
||||||
|
|
||||||
|
|
@ -1978,7 +1978,7 @@ where
|
||||||
if let Ok(result) = self.db.routing_mut().add_inventory([&rid], nid, time) {
|
if let Ok(result) = self.db.routing_mut().add_inventory([&rid], nid, time) {
|
||||||
if let &[(_, InsertResult::SeedAdded)] = result.as_slice() {
|
if let &[(_, InsertResult::SeedAdded)] = result.as_slice() {
|
||||||
self.emitter.emit(Event::SeedDiscovered { rid, nid });
|
self.emitter.emit(Event::SeedDiscovered { rid, nid });
|
||||||
info!(target: "service", "Routing table updated for {} with seed {nid}", rid);
|
info!(target: "service", "Routing table updated for {rid} with seed {nid}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2143,8 +2143,7 @@ where
|
||||||
if refs.push(refs_at).is_err() {
|
if refs.push(refs_at).is_err() {
|
||||||
warn!(
|
warn!(
|
||||||
target: "service",
|
target: "service",
|
||||||
"refs announcement limit ({}) exceeded, peers will see only some of your repository references",
|
"refs announcement limit ({REF_REMOTE_LIMIT}) exceeded, peers will see only some of your repository references",
|
||||||
REF_REMOTE_LIMIT,
|
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ pub use store::{AnnouncementId, Error, RelayStatus, Store};
|
||||||
|
|
||||||
/// This node's user agent string.
|
/// This node's user agent string.
|
||||||
pub static PROTOCOL_VERSION_STRING: LazyLock<UserAgent> = LazyLock::new(|| {
|
pub static PROTOCOL_VERSION_STRING: LazyLock<UserAgent> = LazyLock::new(|| {
|
||||||
FromStr::from_str(format!("/radicle:{}/", PROTOCOL_VERSION).as_str())
|
FromStr::from_str(format!("/radicle:{PROTOCOL_VERSION}/").as_str())
|
||||||
.expect("user agent is valid")
|
.expect("user agent is valid")
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -205,7 +205,7 @@ impl Session {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_connecting(&self) -> bool {
|
pub fn is_connecting(&self) -> bool {
|
||||||
matches!(self.state, State::Attempted { .. })
|
matches!(self.state, State::Attempted)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_stable(&self) -> bool {
|
pub fn is_stable(&self) -> bool {
|
||||||
|
|
|
||||||
|
|
@ -347,7 +347,7 @@ impl<M: wire::Decode> wire::Decode for Frame<M> {
|
||||||
|
|
||||||
Ok(frame)
|
Ok(frame)
|
||||||
}
|
}
|
||||||
Ok(StreamKind::Git { .. }) => {
|
Ok(StreamKind::Git) => {
|
||||||
let data = varint::payload::decode(buf)?;
|
let data = varint::payload::decode(buf)?;
|
||||||
Ok(Frame::git(stream, data))
|
Ok(Frame::git(stream, data))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -866,13 +866,10 @@ fn push_ref(
|
||||||
[],
|
[],
|
||||||
)
|
)
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
Error::Io(std::io::Error::new(
|
Error::Io(std::io::Error::other(format!(
|
||||||
std::io::ErrorKind::Other,
|
|
||||||
format!(
|
|
||||||
"failed to run `git push {url} {refspec}` in {:?}: {err}",
|
"failed to run `git push {url} {refspec}` in {:?}: {err}",
|
||||||
working.path()
|
working.path()
|
||||||
),
|
)))
|
||||||
))
|
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ impl Schema {
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
if let Err(e) = print_schema() {
|
if let Err(e) = print_schema() {
|
||||||
eprintln!("{}", e);
|
eprintln!("{e}");
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -180,7 +180,7 @@ pub fn spinner_to(
|
||||||
} => {
|
} => {
|
||||||
let spinner = DEFAULT_STYLE[*cursor];
|
let spinner = DEFAULT_STYLE[*cursor];
|
||||||
|
|
||||||
write!(animation, "\r{}{spinner} {message}", CLEAR_UNTIL_NEWLINE,).ok();
|
write!(animation, "\r{CLEAR_UNTIL_NEWLINE}{spinner} {message}",).ok();
|
||||||
|
|
||||||
*cursor += 1;
|
*cursor += 1;
|
||||||
*cursor %= DEFAULT_STYLE.len();
|
*cursor %= DEFAULT_STYLE.len();
|
||||||
|
|
|
||||||
|
|
@ -90,10 +90,7 @@ impl CanonicalFormatter {
|
||||||
/// Returns a mutable reference to the top of the object stack.
|
/// Returns a mutable reference to the top of the object stack.
|
||||||
fn obj_mut(&mut self) -> Result<&mut Object> {
|
fn obj_mut(&mut self) -> Result<&mut Object> {
|
||||||
self.object_stack.last_mut().ok_or_else(|| {
|
self.object_stack.last_mut().ok_or_else(|| {
|
||||||
Error::new(
|
Error::other("serde_json called an object method without calling begin_object first")
|
||||||
ErrorKind::Other,
|
|
||||||
"serde_json called an object method without calling begin_object first",
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -192,8 +189,7 @@ impl Formatter for CanonicalFormatter {
|
||||||
|
|
||||||
fn end_object<W: Write + ?Sized>(&mut self, writer: &mut W) -> Result<()> {
|
fn end_object<W: Write + ?Sized>(&mut self, writer: &mut W) -> Result<()> {
|
||||||
let object = self.object_stack.pop().ok_or_else(|| {
|
let object = self.object_stack.pop().ok_or_else(|| {
|
||||||
Error::new(
|
Error::other(
|
||||||
ErrorKind::Other,
|
|
||||||
"serde_json called Formatter::end_object object method
|
"serde_json called Formatter::end_object object method
|
||||||
without calling begin_object first",
|
without calling begin_object first",
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -663,9 +663,9 @@ impl Patch {
|
||||||
// The patch author can edit the patch and change its state.
|
// The patch author can edit the patch and change its state.
|
||||||
Action::Edit { .. } => Authorization::from(actor == author),
|
Action::Edit { .. } => Authorization::from(actor == author),
|
||||||
Action::Lifecycle { state } => Authorization::from(match state {
|
Action::Lifecycle { state } => Authorization::from(match state {
|
||||||
Lifecycle::Open { .. } => actor == author,
|
Lifecycle::Open => actor == author,
|
||||||
Lifecycle::Draft { .. } => actor == author,
|
Lifecycle::Draft => actor == author,
|
||||||
Lifecycle::Archived { .. } => actor == author,
|
Lifecycle::Archived => actor == author,
|
||||||
}),
|
}),
|
||||||
// Only delegates can carry out these actions.
|
// Only delegates can carry out these actions.
|
||||||
Action::Label { labels } => {
|
Action::Label { labels } => {
|
||||||
|
|
|
||||||
|
|
@ -744,10 +744,7 @@ where
|
||||||
return Ok(String::from_utf8_lossy(out).into());
|
return Ok(String::from_utf8_lossy(out).into());
|
||||||
}
|
}
|
||||||
|
|
||||||
Err(io::Error::new(
|
Err(io::Error::other(String::from_utf8_lossy(&output.stderr)))
|
||||||
io::ErrorKind::Other,
|
|
||||||
String::from_utf8_lossy(&output.stderr),
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Functions that call to the `git` CLI instead of `git2`.
|
/// Functions that call to the `git` CLI instead of `git2`.
|
||||||
|
|
|
||||||
|
|
@ -294,7 +294,7 @@ mod test {
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let verified = super::verify(raw);
|
let verified = super::verify(raw);
|
||||||
assert!(verified.is_ok(), "Unexpected error {:?}", verified);
|
assert!(verified.is_ok(), "Unexpected error {verified:?}");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
||||||
|
|
@ -784,7 +784,6 @@ impl Session {
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
||||||
|
|
||||||
pub struct Seed {
|
pub struct Seed {
|
||||||
/// The Node ID.
|
/// The Node ID.
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
|
|
|
||||||
|
|
@ -745,7 +745,7 @@ mod test {
|
||||||
let path = tmp.path().join("Home").join("Radicle");
|
let path = tmp.path().join("Home").join("Radicle");
|
||||||
fs::create_dir_all(path.clone()).unwrap();
|
fs::create_dir_all(path.clone()).unwrap();
|
||||||
|
|
||||||
let last = tmp.path().components().last().unwrap();
|
let last = tmp.path().components().next_back().unwrap();
|
||||||
let home = Home::new(
|
let home = Home::new(
|
||||||
tmp.path()
|
tmp.path()
|
||||||
.join("..")
|
.join("..")
|
||||||
|
|
|
||||||
|
|
@ -417,8 +417,8 @@ impl Remote<Verified> {
|
||||||
let ns = self.id.to_namespace();
|
let ns = self.id.to_namespace();
|
||||||
// Nb. the references in Refs are expected to be Qualified
|
// Nb. the references in Refs are expected to be Qualified
|
||||||
self.refs
|
self.refs
|
||||||
.iter()
|
.keys()
|
||||||
.map(|(name, _)| {
|
.map(|name| {
|
||||||
let name = PatternString::from(ns.join(name));
|
let name = PatternString::from(ns.join(name));
|
||||||
Refspec {
|
Refspec {
|
||||||
src: name.clone(),
|
src: name.clone(),
|
||||||
|
|
|
||||||
|
|
@ -219,7 +219,7 @@ impl Storage {
|
||||||
if self.contains(&rid)? {
|
if self.contains(&rid)? {
|
||||||
return Err(Error::Io(io::Error::new(
|
return Err(Error::Io(io::Error::new(
|
||||||
io::ErrorKind::AlreadyExists,
|
io::ErrorKind::AlreadyExists,
|
||||||
format!("refusing to create '{}.lock'", rid),
|
format!("refusing to create '{rid}.lock'"),
|
||||||
))
|
))
|
||||||
.into());
|
.into());
|
||||||
}
|
}
|
||||||
|
|
@ -852,7 +852,7 @@ impl WriteRepository for Repository {
|
||||||
self.raw()
|
self.raw()
|
||||||
.reference(&branch_ref, *new, true, "set-local-branch (radicle)")?;
|
.reference(&branch_ref, *new, true, "set-local-branch (radicle)")?;
|
||||||
|
|
||||||
log::debug!(target: "storage", "Setting ref: {} -> {}", head_ref, branch_ref);
|
log::debug!(target: "storage", "Setting ref: {head_ref} -> {branch_ref}");
|
||||||
self.raw()
|
self.raw()
|
||||||
.reference_symbolic(&head_ref, &branch_ref, true, "set-head (radicle)")?;
|
.reference_symbolic(&head_ref, &branch_ref, true, "set-head (radicle)")?;
|
||||||
|
|
||||||
|
|
@ -1023,8 +1023,8 @@ mod tests {
|
||||||
let mut refs = repo
|
let mut refs = repo
|
||||||
.references_of(signer.public_key())
|
.references_of(signer.public_key())
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.iter()
|
.keys()
|
||||||
.map(|(r, _)| r.to_string())
|
.map(|r| r.to_string())
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
refs.sort();
|
refs.sort();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -156,8 +156,7 @@ impl cob::object::Storage for Repository {
|
||||||
(*entry).into(),
|
(*entry).into(),
|
||||||
true,
|
true,
|
||||||
&format!(
|
&format!(
|
||||||
"Updating collaborative object '{}/{}' with new entry {}",
|
"Updating collaborative object '{typename}/{object_id}' with new entry {entry}",
|
||||||
typename, object_id, entry,
|
|
||||||
),
|
),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
|
@ -433,8 +432,7 @@ impl<R: storage::WriteRepository> cob::object::Storage for DraftStore<'_, R> {
|
||||||
(*entry).into(),
|
(*entry).into(),
|
||||||
true,
|
true,
|
||||||
&format!(
|
&format!(
|
||||||
"Updating draft collaborative object '{}/{}' with new entry {}",
|
"Updating draft collaborative object '{typename}/{object_id}' with new entry {entry}",
|
||||||
typename, object_id, entry,
|
|
||||||
),
|
),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -341,7 +341,7 @@ impl SignedRefs<Verified> {
|
||||||
Ok(oid) => Ok(Updated::Updated { oid: oid.into() }),
|
Ok(oid) => Ok(Updated::Updated { oid: oid.into() }),
|
||||||
Err(e) => match (e.class(), e.code()) {
|
Err(e) => match (e.class(), e.code()) {
|
||||||
(git2::ErrorClass::Object, git2::ErrorCode::Modified) => {
|
(git2::ErrorClass::Object, git2::ErrorCode::Modified) => {
|
||||||
log::warn!("Concurrent modification of refs: {:?}", e);
|
log::warn!("Concurrent modification of refs: {e:?}");
|
||||||
|
|
||||||
Err(Error::Git(e))
|
Err(Error::Git(e))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue