Rust 1.67
Rust 1.67 was announced[0]. Update the necessary files for running 1.67 and fix the clippy suggestions for string interpolation. [0]: https://blog.rust-lang.org/2023/01/26/Rust-1.67.0.html Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com> X-Clacks-Overhead: GNU Terry Pratchett
This commit is contained in:
parent
c1ba45fcd8
commit
3f48c2c516
|
|
@ -12,7 +12,7 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: dtolnay/rust-toolchain@1.66
|
- uses: dtolnay/rust-toolchain@1.67
|
||||||
- run: cargo build --all-features
|
- run: cargo build --all-features
|
||||||
env:
|
env:
|
||||||
RUSTFLAGS: -D warnings
|
RUSTFLAGS: -D warnings
|
||||||
|
|
@ -35,7 +35,7 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: dtolnay/rust-toolchain@1.66
|
- uses: dtolnay/rust-toolchain@1.67
|
||||||
- run: cargo doc --all --all-features
|
- run: cargo doc --all --all-features
|
||||||
env:
|
env:
|
||||||
RUSTDOCFLAGS: -D warnings
|
RUSTDOCFLAGS: -D warnings
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,10 @@
|
||||||
"homepage": "https://github.com/nmattia/niv",
|
"homepage": "https://github.com/nmattia/niv",
|
||||||
"owner": "nmattia",
|
"owner": "nmattia",
|
||||||
"repo": "niv",
|
"repo": "niv",
|
||||||
"rev": "351d8bc316bf901a81885bab5f52687ec8ccab6e",
|
"rev": "689d0e5539eddd0b0f566aee7bb18629eee7df74",
|
||||||
"sha256": "1yzhz7ihkh6p2sxhp3amqfbmm2yqzaadqqii1xijymvl8alw5rrr",
|
"sha256": "1rld3lk42l6b01f2gcrhq8qm9vry1awmfl29zmpiqda9dy89vbx0",
|
||||||
"type": "tarball",
|
"type": "tarball",
|
||||||
"url": "https://github.com/nmattia/niv/archive/351d8bc316bf901a81885bab5f52687ec8ccab6e.tar.gz",
|
"url": "https://github.com/nmattia/niv/archive/689d0e5539eddd0b0f566aee7bb18629eee7df74.tar.gz",
|
||||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
|
|
@ -29,10 +29,10 @@
|
||||||
"homepage": "",
|
"homepage": "",
|
||||||
"owner": "oxalica",
|
"owner": "oxalica",
|
||||||
"repo": "rust-overlay",
|
"repo": "rust-overlay",
|
||||||
"rev": "7da2f6b3a0c32f661cb2864d7fbd1d7e6f0c7543",
|
"rev": "383a4acfd11d778d5c2efcf28376cbd845eeaedf",
|
||||||
"sha256": "1daw246p4aimvx9h3cf034dsyimh9d2ww19v4fx45mcmlqw1mx42",
|
"sha256": "1p1vcmfwhi6397xb4bq95dsc185mf2wg8jw8wv51kn3n1xkwlh5s",
|
||||||
"type": "tarball",
|
"type": "tarball",
|
||||||
"url": "https://github.com/oxalica/rust-overlay/archive/7da2f6b3a0c32f661cb2864d7fbd1d7e6f0c7543.tar.gz",
|
"url": "https://github.com/oxalica/rust-overlay/archive/383a4acfd11d778d5c2efcf28376cbd845eeaedf.tar.gz",
|
||||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
2
build.rs
2
build.rs
|
|
@ -18,6 +18,6 @@ fn main() {
|
||||||
})
|
})
|
||||||
.unwrap_or_else(|| String::from("unknown"));
|
.unwrap_or_else(|| String::from("unknown"));
|
||||||
|
|
||||||
println!("cargo:rustc-env=GIT_HEAD={}", hash);
|
println!("cargo:rustc-env=GIT_HEAD={hash}");
|
||||||
println!("cargo:rustc-rerun-if-changed=.git/HEAD");
|
println!("cargo:rustc-rerun-if-changed=.git/HEAD");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ impl Args for Options {
|
||||||
}
|
}
|
||||||
Value(val) if id.is_none() => {
|
Value(val) if id.is_none() => {
|
||||||
let val = val.to_string_lossy();
|
let val = val.to_string_lossy();
|
||||||
let val = Id::from_str(&val).context(format!("invalid id '{}'", val))?;
|
let val = Id::from_str(&val).context(format!("invalid id '{val}'"))?;
|
||||||
|
|
||||||
id = Some(val);
|
id = Some(val);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -288,8 +288,8 @@ pub fn setup_signing(
|
||||||
git::read_gitsigners(repo).context("error reading .gitsigners file")?;
|
git::read_gitsigners(repo).context("error reading .gitsigners file")?;
|
||||||
|
|
||||||
if ssh_keys.contains(&ssh_key) {
|
if ssh_keys.contains(&ssh_key) {
|
||||||
term::success!("Signing key is already in {} file", gitsigners);
|
term::success!("Signing key is already in {gitsigners} file");
|
||||||
} else if term::confirm(format!("Add signing key to {}?", gitsigners)) {
|
} else if term::confirm(format!("Add signing key to {gitsigners}?")) {
|
||||||
git::add_gitsigners(repo, [node_id])?;
|
git::add_gitsigners(repo, [node_id])?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -175,10 +175,10 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
|
||||||
term::format::yellow(oid),
|
term::format::yellow(oid),
|
||||||
);
|
);
|
||||||
if let Ok(parent) = tip.parent_id(0) {
|
if let Ok(parent) = tip.parent_id(0) {
|
||||||
println!("parent {}", parent);
|
println!("parent {parent}");
|
||||||
}
|
}
|
||||||
println!("blob {}", blob.id());
|
println!("blob {}", blob.id());
|
||||||
println!("date {}", time);
|
println!("date {time}");
|
||||||
println!();
|
println!();
|
||||||
|
|
||||||
if let Some(msg) = tip.message() {
|
if let Some(msg) = tip.message() {
|
||||||
|
|
|
||||||
|
|
@ -138,7 +138,7 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
|
||||||
let repository = profile.storage.repository(id)?;
|
let repository = profile.storage.repository(id)?;
|
||||||
let _project = repository
|
let _project = repository
|
||||||
.identity_of(profile.id())
|
.identity_of(profile.id())
|
||||||
.context(format!("couldn't load project {} from local state", id))?;
|
.context(format!("couldn't load project {id} from local state"))?;
|
||||||
let repository = profile.storage.repository(id)?;
|
let repository = profile.storage.repository(id)?;
|
||||||
let mut patches = Patches::open(*profile.id(), &repository)?;
|
let mut patches = Patches::open(*profile.id(), &repository)?;
|
||||||
|
|
||||||
|
|
@ -232,7 +232,7 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
|
||||||
"{} {} {} ({}) by {} into {} ({}) via {}...",
|
"{} {} {} ({}) by {} into {} ({}) via {}...",
|
||||||
term::format::bold("Merging"),
|
term::format::bold("Merging"),
|
||||||
term::format::tertiary(term::format::cob(&patch_id)),
|
term::format::tertiary(term::format::cob(&patch_id)),
|
||||||
term::format::dim(format!("R{}", revision_ix)),
|
term::format::dim(format!("R{revision_ix}")),
|
||||||
term::format::secondary(term::format::oid(revision.oid)),
|
term::format::secondary(term::format::oid(revision.oid)),
|
||||||
term::format::tertiary(patch.author().id),
|
term::format::tertiary(patch.author().id),
|
||||||
term::format::highlight(branch),
|
term::format::highlight(branch),
|
||||||
|
|
@ -302,12 +302,12 @@ fn merge_commit(
|
||||||
write!(&mut merge_msg, "\n\n")?;
|
write!(&mut merge_msg, "\n\n")?;
|
||||||
|
|
||||||
if !description.is_empty() {
|
if !description.is_empty() {
|
||||||
write!(&mut merge_msg, "{}", description)?;
|
write!(&mut merge_msg, "{description}")?;
|
||||||
write!(&mut merge_msg, "\n\n")?;
|
write!(&mut merge_msg, "\n\n")?;
|
||||||
}
|
}
|
||||||
writeln!(&mut merge_msg, "Rad-Patch: {}", patch_id)?;
|
writeln!(&mut merge_msg, "Rad-Patch: {patch_id}")?;
|
||||||
writeln!(&mut merge_msg, "Rad-Author: {}", patch.author().id())?;
|
writeln!(&mut merge_msg, "Rad-Author: {}", patch.author().id())?;
|
||||||
writeln!(&mut merge_msg, "Rad-Committer: {}", whoami)?;
|
writeln!(&mut merge_msg, "Rad-Committer: {whoami}")?;
|
||||||
writeln!(&mut merge_msg)?;
|
writeln!(&mut merge_msg)?;
|
||||||
writeln!(&mut merge_msg, "{}", MERGE_HELP_MSG.trim())?;
|
writeln!(&mut merge_msg, "{}", MERGE_HELP_MSG.trim())?;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ pub fn pretty_sync_status(
|
||||||
let ahead = term::format::positive(a);
|
let ahead = term::format::positive(a);
|
||||||
let behind = term::format::negative(b);
|
let behind = term::format::negative(b);
|
||||||
|
|
||||||
Ok(format!("ahead {}, behind {}", ahead, behind))
|
Ok(format!("ahead {ahead}, behind {behind}"))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Make a human friendly string for commit version information.
|
/// Make a human friendly string for commit version information.
|
||||||
|
|
@ -143,7 +143,7 @@ pub fn patch_commits<'a>(
|
||||||
) -> anyhow::Result<Vec<git::raw::Commit<'a>>> {
|
) -> anyhow::Result<Vec<git::raw::Commit<'a>>> {
|
||||||
let mut commits = Vec::new();
|
let mut commits = Vec::new();
|
||||||
let mut revwalk = repo.revwalk()?;
|
let mut revwalk = repo.revwalk()?;
|
||||||
revwalk.push_range(&format!("{}..{}", base, head))?;
|
revwalk.push_range(&format!("{base}..{head}"))?;
|
||||||
|
|
||||||
for rev in revwalk {
|
for rev in revwalk {
|
||||||
let commit = repo.find_commit(rev?)?;
|
let commit = repo.find_commit(rev?)?;
|
||||||
|
|
|
||||||
|
|
@ -229,7 +229,7 @@ pub fn run(
|
||||||
let commit_message = head_commit
|
let commit_message = head_commit
|
||||||
.message()
|
.message()
|
||||||
.ok_or(anyhow!("commit summary is not valid UTF-8; aborting"))?;
|
.ok_or(anyhow!("commit summary is not valid UTF-8; aborting"))?;
|
||||||
let message = message.get(&format!("{}{}", commit_message, PATCH_MSG));
|
let message = message.get(&format!("{commit_message}{PATCH_MSG}"));
|
||||||
let (title, description) = message.split_once("\n\n").unwrap_or((&message, ""));
|
let (title, description) = message.split_once("\n\n").unwrap_or((&message, ""));
|
||||||
let (title, description) = (title.trim(), description.trim());
|
let (title, description) = (title.trim(), description.trim());
|
||||||
let description = description.replace(PATCH_MSG.trim(), ""); // Delete help message.
|
let description = description.replace(PATCH_MSG.trim(), ""); // Delete help message.
|
||||||
|
|
@ -289,7 +289,7 @@ fn update<G: Signer>(
|
||||||
term::info!(
|
term::info!(
|
||||||
"{} {} ({}) -> {} ({})",
|
"{} {} ({}) -> {} ({})",
|
||||||
term::format::tertiary(term::format::cob(&patch_id)),
|
term::format::tertiary(term::format::cob(&patch_id)),
|
||||||
term::format::dim(format!("R{}", current_version)),
|
term::format::dim(format!("R{current_version}")),
|
||||||
term::format::secondary(term::format::oid(current_revision.oid)),
|
term::format::secondary(term::format::oid(current_revision.oid)),
|
||||||
term::format::dim(format!("R{}", current_version + 1)),
|
term::format::dim(format!("R{}", current_version + 1)),
|
||||||
term::format::secondary(term::format::oid(*head)),
|
term::format::secondary(term::format::oid(*head)),
|
||||||
|
|
|
||||||
|
|
@ -29,11 +29,11 @@ pub fn run(
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
let patches = patch::Patches::open(profile.public_key, storage)?;
|
let patches = patch::Patches::open(profile.public_key, storage)?;
|
||||||
let Some(patch) = patches.get(patch_id)? else {
|
let Some(patch) = patches.get(patch_id)? else {
|
||||||
anyhow::bail!("Patch `{}` not found", patch_id);
|
anyhow::bail!("Patch `{patch_id}` not found");
|
||||||
};
|
};
|
||||||
|
|
||||||
term::blank();
|
term::blank();
|
||||||
term::print(format!("patch {}", patch_id));
|
term::print(format!("patch {patch_id}"));
|
||||||
term::blank();
|
term::blank();
|
||||||
|
|
||||||
term::patch::print_title_desc(patch.title(), patch.description().unwrap_or(""));
|
term::patch::print_title_desc(patch.title(), patch.description().unwrap_or(""));
|
||||||
|
|
|
||||||
|
|
@ -138,13 +138,13 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
|
||||||
let repository = profile.storage.repository(id)?;
|
let repository = profile.storage.repository(id)?;
|
||||||
let _project = repository
|
let _project = repository
|
||||||
.identity_of(profile.id())
|
.identity_of(profile.id())
|
||||||
.context(format!("couldn't load project {} from local state", id))?;
|
.context(format!("couldn't load project {id} from local state"))?;
|
||||||
let mut patches = Patches::open(*profile.id(), &repository)?;
|
let mut patches = Patches::open(*profile.id(), &repository)?;
|
||||||
|
|
||||||
let patch_id = options.id;
|
let patch_id = options.id;
|
||||||
let mut patch = patches
|
let mut patch = patches
|
||||||
.get_mut(&patch_id)
|
.get_mut(&patch_id)
|
||||||
.context(format!("couldn't find patch {} locally", patch_id))?;
|
.context(format!("couldn't find patch {patch_id} locally"))?;
|
||||||
let patch_id_pretty = term::format::tertiary(term::format::cob(&patch_id));
|
let patch_id_pretty = term::format::tertiary(term::format::cob(&patch_id));
|
||||||
let revision_ix = options.revision.unwrap_or_else(|| patch.version());
|
let revision_ix = options.revision.unwrap_or_else(|| patch.version());
|
||||||
let (revision_id, _) = patch
|
let (revision_id, _) = patch
|
||||||
|
|
@ -162,7 +162,7 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
|
||||||
"{} {} {} by {}?",
|
"{} {} {} by {}?",
|
||||||
verdict_pretty,
|
verdict_pretty,
|
||||||
patch_id_pretty,
|
patch_id_pretty,
|
||||||
term::format::dim(format!("R{}", revision_ix)),
|
term::format::dim(format!("R{revision_ix}")),
|
||||||
term::format::tertiary(patch.author().id())
|
term::format::tertiary(patch.author().id())
|
||||||
)) {
|
)) {
|
||||||
anyhow::bail!("Patch review aborted");
|
anyhow::bail!("Patch review aborted");
|
||||||
|
|
|
||||||
|
|
@ -195,7 +195,7 @@ pub fn set_tracking(repo: &Repository, remote: &NodeId, branch: &str) -> anyhow:
|
||||||
/// Get the name of the remote of the given branch, if any.
|
/// Get the name of the remote of the given branch, if any.
|
||||||
pub fn branch_remote(repo: &Repository, branch: &str) -> anyhow::Result<String> {
|
pub fn branch_remote(repo: &Repository, branch: &str) -> anyhow::Result<String> {
|
||||||
let cfg = repo.config()?;
|
let cfg = repo.config()?;
|
||||||
let remote = cfg.get_string(&format!("branch.{}.remote", branch))?;
|
let remote = cfg.get_string(&format!("branch.{branch}.remote"))?;
|
||||||
|
|
||||||
Ok(remote)
|
Ok(remote)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ fn main() {
|
||||||
Ok(_) => process::exit(0),
|
Ok(_) => process::exit(0),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
if let Some(err) = err {
|
if let Some(err) = err {
|
||||||
term::error(format!("Error: rad: {}", err));
|
term::error(format!("Error: rad: {err}"));
|
||||||
}
|
}
|
||||||
process::exit(1);
|
process::exit(1);
|
||||||
}
|
}
|
||||||
|
|
@ -64,15 +64,15 @@ fn parse_args() -> anyhow::Result<Command> {
|
||||||
|
|
||||||
fn print_version() {
|
fn print_version() {
|
||||||
if VERSION.contains("-dev") {
|
if VERSION.contains("-dev") {
|
||||||
println!("{} {}+{}", NAME, VERSION, GIT_HEAD)
|
println!("{NAME} {VERSION}+{GIT_HEAD}")
|
||||||
} else {
|
} else {
|
||||||
println!("{} {}", NAME, VERSION)
|
println!("{NAME} {VERSION}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_help() -> anyhow::Result<()> {
|
fn print_help() -> anyhow::Result<()> {
|
||||||
print_version();
|
print_version();
|
||||||
println!("{}", DESCRIPTION);
|
println!("{DESCRIPTION}");
|
||||||
println!();
|
println!();
|
||||||
|
|
||||||
rad_help::run(Default::default(), term::profile)
|
rad_help::run(Default::default(), term::profile)
|
||||||
|
|
@ -285,7 +285,7 @@ fn run_other(exe: &str, args: &[OsString]) -> Result<(), Option<anyhow::Error>>
|
||||||
args.to_vec(),
|
args.to_vec(),
|
||||||
),
|
),
|
||||||
_ => {
|
_ => {
|
||||||
let exe = format!("{}-{}", NAME, exe);
|
let exe = format!("{NAME}-{exe}");
|
||||||
let status = process::Command::new(exe.clone()).args(args).status();
|
let status = process::Command::new(exe.clone()).args(args).status();
|
||||||
|
|
||||||
match status {
|
match status {
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ where
|
||||||
match cmd.run(options, self::profile) {
|
match cmd.run(options, self::profile) {
|
||||||
Ok(()) => process::exit(0),
|
Ok(()) => process::exit(0),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
term::fail(&format!("{} failed", action), &err);
|
term::fail(&format!("{action} failed"), &err);
|
||||||
process::exit(1);
|
process::exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,8 +56,8 @@ where
|
||||||
|
|
||||||
pub fn format(arg: lexopt::Arg) -> OsString {
|
pub fn format(arg: lexopt::Arg) -> OsString {
|
||||||
match arg {
|
match arg {
|
||||||
lexopt::Arg::Long(flag) => format!("--{}", flag).into(),
|
lexopt::Arg::Long(flag) => format!("--{flag}").into(),
|
||||||
lexopt::Arg::Short(flag) => format!("-{}", flag).into(),
|
lexopt::Arg::Short(flag) => format!("-{flag}").into(),
|
||||||
lexopt::Arg::Value(val) => val,
|
lexopt::Arg::Value(val) => val,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ pub fn node(node: &NodeId) -> String {
|
||||||
let start = node.chars().take(7).collect::<String>();
|
let start = node.chars().take(7).collect::<String>();
|
||||||
let end = node.chars().skip(node.len() - 7).collect::<String>();
|
let end = node.chars().skip(node.len() - 7).collect::<String>();
|
||||||
|
|
||||||
format!("{}…{}", start, end)
|
format!("{start}…{end}")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Format a git Oid.
|
/// Format a git Oid.
|
||||||
|
|
@ -83,7 +83,7 @@ impl<'a> fmt::Display for Identity<'a> {
|
||||||
term::format::dim(username)
|
term::format::dim(username)
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
write!(f, "{} {}", node_id, username)
|
write!(f, "{node_id} {username}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -117,22 +117,19 @@ pub fn highlight<D: std::fmt::Display>(input: D) -> String {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn badge_primary<D: std::fmt::Display>(input: D) -> String {
|
pub fn badge_primary<D: std::fmt::Display>(input: D) -> String {
|
||||||
style(format!(" {} ", input))
|
style(format!(" {input} ")).magenta().reverse().to_string()
|
||||||
.magenta()
|
|
||||||
.reverse()
|
|
||||||
.to_string()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn badge_positive<D: std::fmt::Display>(input: D) -> String {
|
pub fn badge_positive<D: std::fmt::Display>(input: D) -> String {
|
||||||
style(format!(" {} ", input)).green().reverse().to_string()
|
style(format!(" {input} ")).green().reverse().to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn badge_negative<D: std::fmt::Display>(input: D) -> String {
|
pub fn badge_negative<D: std::fmt::Display>(input: D) -> String {
|
||||||
style(format!(" {} ", input)).red().reverse().to_string()
|
style(format!(" {input} ")).red().reverse().to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn badge_secondary<D: std::fmt::Display>(input: D) -> String {
|
pub fn badge_secondary<D: std::fmt::Display>(input: D) -> String {
|
||||||
style(format!(" {} ", input)).blue().reverse().to_string()
|
style(format!(" {input} ")).blue().reverse().to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn bold<D: std::fmt::Display>(input: D) -> String {
|
pub fn bold<D: std::fmt::Display>(input: D) -> String {
|
||||||
|
|
|
||||||
|
|
@ -45,15 +45,11 @@ pub use success;
|
||||||
pub use tip;
|
pub use tip;
|
||||||
|
|
||||||
pub fn success_args(args: fmt::Arguments) {
|
pub fn success_args(args: fmt::Arguments) {
|
||||||
println!("{} {}", style("ok").green().reverse(), args);
|
println!("{} {args}", style("ok").green().reverse());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn tip_args(args: fmt::Arguments) {
|
pub fn tip_args(args: fmt::Arguments) {
|
||||||
println!(
|
println!("{} {}", style("=>").blue(), style(format!("{args}")).dim());
|
||||||
"{} {}",
|
|
||||||
style("=>").blue(),
|
|
||||||
style(format!("{}", args)).dim()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn width() -> Option<usize> {
|
pub fn width() -> Option<usize> {
|
||||||
|
|
@ -77,34 +73,34 @@ pub fn blank() {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn print(msg: impl fmt::Display) {
|
pub fn print(msg: impl fmt::Display) {
|
||||||
println!("{}", msg);
|
println!("{msg}");
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn prefixed(prefix: &str, text: &str) -> String {
|
pub fn prefixed(prefix: &str, text: &str) -> String {
|
||||||
text.split('\n')
|
text.split('\n')
|
||||||
.map(|line| format!("{}{}\n", prefix, line))
|
.map(|line| format!("{prefix}{line}\n"))
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn help(name: &str, version: &str, description: &str, usage: &str) {
|
pub fn help(name: &str, version: &str, description: &str, usage: &str) {
|
||||||
println!("rad-{} {}\n{}\n{}", name, version, description, usage);
|
println!("rad-{name} {version}\n{description}\n{usage}");
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn usage(name: &str, usage: &str) {
|
pub fn usage(name: &str, usage: &str) {
|
||||||
eprintln!(
|
eprintln!(
|
||||||
"{} {}\n{}",
|
"{} {}\n{}",
|
||||||
style("==").red(),
|
style("==").red(),
|
||||||
style(format!("Error: rad-{}: invalid usage", name)).red(),
|
style(format!("Error: rad-{name}: invalid usage")).red(),
|
||||||
style(prefixed(TAB, usage)).red().dim()
|
style(prefixed(TAB, usage)).red().dim()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn eprintln(prefix: impl fmt::Display, msg: impl fmt::Display) {
|
pub fn eprintln(prefix: impl fmt::Display, msg: impl fmt::Display) {
|
||||||
eprintln!("{} {}", prefix, msg);
|
eprintln!("{prefix} {msg}");
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn indented(msg: impl fmt::Display) {
|
pub fn indented(msg: impl fmt::Display) {
|
||||||
println!("{}{}", TAB, msg);
|
println!("{TAB}{msg}");
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn subcommand(msg: impl fmt::Display) {
|
pub fn subcommand(msg: impl fmt::Display) {
|
||||||
|
|
@ -233,7 +229,7 @@ pub struct Optional<T> {
|
||||||
impl<T: fmt::Display> fmt::Display for Optional<T> {
|
impl<T: fmt::Display> fmt::Display for Optional<T> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
if let Some(val) = &self.option {
|
if let Some(val) = &self.option {
|
||||||
write!(f, "{}", val)
|
write!(f, "{val}")
|
||||||
} else {
|
} else {
|
||||||
write!(f, "")
|
write!(f, "")
|
||||||
}
|
}
|
||||||
|
|
@ -392,5 +388,5 @@ pub fn markdown(content: &str) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn _info(args: std::fmt::Arguments) {
|
fn _info(args: std::fmt::Arguments) {
|
||||||
println!("{}", args);
|
println!("{args}");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ pub fn print_commits_ahead_behind(
|
||||||
|
|
||||||
/// Print title and description in a text box.
|
/// Print title and description in a text box.
|
||||||
pub fn print_title_desc(title: &str, description: &str) {
|
pub fn print_title_desc(title: &str, description: &str) {
|
||||||
let title_pretty = &term::format::dim(format!("╭─ {} ───────", title));
|
let title_pretty = &term::format::dim(format!("╭─ {title} ───────"));
|
||||||
term::print(title_pretty);
|
term::print(title_pretty);
|
||||||
term::blank();
|
term::blank();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ impl<const W: usize> Table<W> {
|
||||||
|
|
||||||
for (i, cell) in row.iter().enumerate() {
|
for (i, cell) in row.iter().enumerate() {
|
||||||
if i == cells - 1 || self.opts.overflow {
|
if i == cells - 1 || self.opts.overflow {
|
||||||
write!(output, "{}", cell).ok();
|
write!(output, "{cell}").ok();
|
||||||
} else {
|
} else {
|
||||||
write!(
|
write!(
|
||||||
output,
|
output,
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ impl Person {
|
||||||
key: crypto::PublicKey,
|
key: crypto::PublicKey,
|
||||||
) -> Result<Self, storage::error::Identity> {
|
) -> Result<Self, storage::error::Identity> {
|
||||||
let repo = repo.as_raw();
|
let repo = repo.as_raw();
|
||||||
let refname = format!("refs/rad/identities/{}", name);
|
let refname = format!("refs/rad/identities/{name}");
|
||||||
let payload = Payload {
|
let payload = Payload {
|
||||||
name: Name(name.to_owned()),
|
name: Name(name.to_owned()),
|
||||||
key,
|
key,
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ impl Project {
|
||||||
delegate: crypto::PublicKey,
|
delegate: crypto::PublicKey,
|
||||||
) -> Result<Self, storage::error::Identity> {
|
) -> Result<Self, storage::error::Identity> {
|
||||||
let repo = repo.as_raw();
|
let repo = repo.as_raw();
|
||||||
let refname = format!("refs/rad/identities/{}", name);
|
let refname = format!("refs/rad/identities/{name}");
|
||||||
let payload = Payload {
|
let payload = Payload {
|
||||||
name: Name(name.to_owned()),
|
name: Name(name.to_owned()),
|
||||||
delegates: Some(delegate).into_iter().collect(),
|
delegates: Some(delegate).into_iter().collect(),
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,7 @@ impl object::Storage for Storage {
|
||||||
typename: &crate::TypeName,
|
typename: &crate::TypeName,
|
||||||
object_id: &ObjectId,
|
object_id: &ObjectId,
|
||||||
) -> Result<object::Objects, Self::ObjectsError> {
|
) -> Result<object::Objects, Self::ObjectsError> {
|
||||||
let glob = format!("refs/rad/*/cobs/{}/{}", typename, object_id);
|
let glob = format!("refs/rad/*/cobs/{typename}/{object_id}");
|
||||||
let remotes = self
|
let remotes = self
|
||||||
.raw
|
.raw
|
||||||
.references_glob(&glob)?
|
.references_glob(&glob)?
|
||||||
|
|
@ -125,7 +125,7 @@ impl object::Storage for Storage {
|
||||||
for r in self.raw.references_glob("refs/rad/*")? {
|
for r in self.raw.references_glob("refs/rad/*")? {
|
||||||
let r = r?;
|
let r = r?;
|
||||||
let name = r.name().unwrap();
|
let name = r.name().unwrap();
|
||||||
println!("NAME: {}", name);
|
println!("NAME: {name}");
|
||||||
let oid = r
|
let oid = r
|
||||||
.target()
|
.target()
|
||||||
.map(ObjectId::from)
|
.map(ObjectId::from)
|
||||||
|
|
|
||||||
|
|
@ -31,14 +31,14 @@ impl AsRef<[u8; 32]> for Digest {
|
||||||
|
|
||||||
impl fmt::Debug for Digest {
|
impl fmt::Debug for Digest {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(f, "Hash({})", self)
|
write!(f, "Hash({self})")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for Digest {
|
impl fmt::Display for Digest {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
for byte in &self.0 {
|
for byte in &self.0 {
|
||||||
write!(f, "{:02x}", byte)?;
|
write!(f, "{byte:02x}")?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ impl fmt::Display for Signature {
|
||||||
|
|
||||||
impl fmt::Debug for Signature {
|
impl fmt::Debug for Signature {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(f, "Signature({})", self)
|
write!(f, "Signature({self})")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -366,7 +366,7 @@ impl From<PublicKey> for String {
|
||||||
|
|
||||||
impl fmt::Debug for PublicKey {
|
impl fmt::Debug for PublicKey {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(f, "PublicKey({})", self)
|
write!(f, "PublicKey({self})")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ pub mod fmt {
|
||||||
let sha = sha2::Sha256::digest(&buf).to_vec();
|
let sha = sha2::Sha256::digest(&buf).to_vec();
|
||||||
let encoded = base64::encode_config(sha, base64::STANDARD_NO_PAD);
|
let encoded = base64::encode_config(sha, base64::STANDARD_NO_PAD);
|
||||||
|
|
||||||
format!("SHA256:{}", encoded)
|
format!("SHA256:{encoded}")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
|
||||||
|
|
@ -185,7 +185,7 @@ impl<K: Eq + Copy + Hash + fmt::Debug, V> Index<&K> for Dag<K, V> {
|
||||||
|
|
||||||
fn index(&self, key: &K) -> &Self::Output {
|
fn index(&self, key: &K) -> &Self::Output {
|
||||||
self.get(key)
|
self.get(key)
|
||||||
.unwrap_or_else(|| panic!("Dag::index: node {:?} not found in graph", key))
|
.unwrap_or_else(|| panic!("Dag::index: node {key:?} not found in graph"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -298,7 +298,7 @@ mod tests {
|
||||||
let expected: &[&[i32]] = &[&[0, 1, 2, 3], &[0, 2, 1, 3]];
|
let expected: &[&[i32]] = &[&[0, 1, 2, 3], &[0, 2, 1, 3]];
|
||||||
let actual = dag.sorted(fastrand::Rng::new());
|
let actual = dag.sorted(fastrand::Rng::new());
|
||||||
|
|
||||||
assert!(expected.contains(&actual.as_slice()), "{:?}", actual);
|
assert!(expected.contains(&actual.as_slice()), "{actual:?}");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ where
|
||||||
}
|
}
|
||||||
_ => Json(Error {
|
_ => Json(Error {
|
||||||
success: false,
|
success: false,
|
||||||
error: format!("{}", rejection),
|
error: format!("{rejection}"),
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -72,7 +72,7 @@ where
|
||||||
}),
|
}),
|
||||||
_ => Json(Error {
|
_ => Json(Error {
|
||||||
success: false,
|
success: false,
|
||||||
error: format!("{}", rejection),
|
error: format!("{rejection}"),
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -254,7 +254,7 @@ async fn git_http_backend(
|
||||||
Err(Error::Backend)
|
Err(Error::Backend)
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
panic!("failed to wait for git-http-backend: {}", err);
|
panic!("failed to wait for git-http-backend: {err}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ pub fn listen<H: Handle<Error = runtime::HandleError>>(
|
||||||
handle.shutdown().ok();
|
handle.shutdown().ok();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
writeln!(stream, "error: {}", e).ok();
|
writeln!(stream, "error: {e}").ok();
|
||||||
|
|
||||||
stream.flush().ok();
|
stream.flush().ok();
|
||||||
stream.shutdown(net::Shutdown::Both).ok();
|
stream.shutdown(net::Shutdown::Both).ok();
|
||||||
|
|
@ -244,30 +244,29 @@ fn fetch<W: Write, H: Handle<Error = runtime::HandleError>>(
|
||||||
{
|
{
|
||||||
match result.result {
|
match result.result {
|
||||||
Ok(updated) => {
|
Ok(updated) => {
|
||||||
writeln!(writer, "ok: {} fetched from {}", &id, result.remote)?;
|
writeln!(writer, "ok: {id} fetched from {}", result.remote)?;
|
||||||
|
|
||||||
for update in updated {
|
for update in updated {
|
||||||
writeln!(writer, "{}", update)?;
|
writeln!(writer, "{update}")?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
writeln!(
|
writeln!(
|
||||||
writer,
|
writer,
|
||||||
"error: {} failed to fetch from {}: {}",
|
"error: {id} failed to fetch from {}: {err}",
|
||||||
&id, result.remote, err
|
result.remote
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(FetchLookup::NotFound) => {
|
Ok(FetchLookup::NotFound) => {
|
||||||
writeln!(writer, "error: {} was not found", &id)?;
|
writeln!(writer, "error: {id} was not found")?;
|
||||||
}
|
}
|
||||||
Ok(FetchLookup::NotTracking) => {
|
Ok(FetchLookup::NotTracking) => {
|
||||||
writeln!(writer, "error: {} is not tracked", &id)?;
|
writeln!(writer, "error: {id} is not tracked")?;
|
||||||
}
|
}
|
||||||
Ok(FetchLookup::Error(err)) => {
|
Ok(FetchLookup::Error(err)) => {
|
||||||
writeln!(writer, "error: {}", err)?;
|
writeln!(writer, "error: {err}")?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ impl Log for Logger {
|
||||||
Level::Debug => message.dimmed(),
|
Level::Debug => message.dimmed(),
|
||||||
Level::Trace => message.white().dimmed(),
|
Level::Trace => message.white().dimmed(),
|
||||||
};
|
};
|
||||||
writeln!(stream, "{}", message).expect("write shouldn't fail");
|
writeln!(stream, "{message}").expect("write shouldn't fail");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -122,13 +122,13 @@ pub enum Command {
|
||||||
impl fmt::Debug for Command {
|
impl fmt::Debug for Command {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
Self::AnnounceRefs(id) => write!(f, "AnnounceRefs({})", id),
|
Self::AnnounceRefs(id) => write!(f, "AnnounceRefs({id})"),
|
||||||
Self::Connect(id, addr) => write!(f, "Connect({}, {})", id, addr),
|
Self::Connect(id, addr) => write!(f, "Connect({id}, {addr})"),
|
||||||
Self::Fetch(id, _) => write!(f, "Fetch({})", id),
|
Self::Fetch(id, _) => write!(f, "Fetch({id})"),
|
||||||
Self::TrackRepo(id, _) => write!(f, "TrackRepo({})", id),
|
Self::TrackRepo(id, _) => write!(f, "TrackRepo({id})"),
|
||||||
Self::UntrackRepo(id, _) => write!(f, "UntrackRepo({})", id),
|
Self::UntrackRepo(id, _) => write!(f, "UntrackRepo({id})"),
|
||||||
Self::TrackNode(id, _, _) => write!(f, "TrackNode({})", id),
|
Self::TrackNode(id, _, _) => write!(f, "TrackNode({id})"),
|
||||||
Self::UntrackNode(id, _) => write!(f, "UntrackNode({})", id),
|
Self::UntrackNode(id, _) => write!(f, "UntrackNode({id})"),
|
||||||
Self::QueryState { .. } => write!(f, "QueryState(..)"),
|
Self::QueryState { .. } => write!(f, "QueryState(..)"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1223,10 +1223,10 @@ impl DisconnectReason {
|
||||||
impl fmt::Display for DisconnectReason {
|
impl fmt::Display for DisconnectReason {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
Self::Dial(err) => write!(f, "{}", err),
|
Self::Dial(err) => write!(f, "{err}"),
|
||||||
Self::Connection(err) => write!(f, "{}", err),
|
Self::Connection(err) => write!(f, "{err}"),
|
||||||
Self::Session(err) => write!(f, "error: {}", err),
|
Self::Session(err) => write!(f, "error: {err}"),
|
||||||
Self::Fetch(err) => write!(f, "fetch: {}", err),
|
Self::Fetch(err) => write!(f, "fetch: {err}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -387,13 +387,13 @@ impl fmt::Debug for Message {
|
||||||
match self {
|
match self {
|
||||||
Self::Initialize { .. } => write!(f, "Initialize(..)"),
|
Self::Initialize { .. } => write!(f, "Initialize(..)"),
|
||||||
Self::Subscribe(Subscribe { since, until, .. }) => {
|
Self::Subscribe(Subscribe { since, until, .. }) => {
|
||||||
write!(f, "Subscribe({}..{})", since, until)
|
write!(f, "Subscribe({since}..{until})")
|
||||||
}
|
}
|
||||||
Self::Announcement(Announcement { node, message, .. }) => {
|
Self::Announcement(Announcement { node, message, .. }) => {
|
||||||
write!(f, "Announcement({}, {:?})", node, message)
|
write!(f, "Announcement({node}, {message:?})")
|
||||||
}
|
}
|
||||||
Self::Ping(Ping { ponglen, zeroes }) => write!(f, "Ping({ponglen}, {:?})", zeroes),
|
Self::Ping(Ping { ponglen, zeroes }) => write!(f, "Ping({ponglen}, {zeroes:?})"),
|
||||||
Self::Pong { zeroes } => write!(f, "Pong({:?})", zeroes),
|
Self::Pong { zeroes } => write!(f, "Pong({zeroes:?})"),
|
||||||
Self::Fetch { rid } => write!(f, "Fetch({rid})"),
|
Self::Fetch { rid } => write!(f, "Fetch({rid})"),
|
||||||
Self::FetchOk { rid } => write!(f, "FetchOk({rid})"),
|
Self::FetchOk { rid } => write!(f, "FetchOk({rid})"),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,9 +22,9 @@ impl Log for Logger {
|
||||||
target => {
|
target => {
|
||||||
if self.enabled(record.metadata()) {
|
if self.enabled(record.metadata()) {
|
||||||
let current = std::thread::current();
|
let current = std::thread::current();
|
||||||
let msg = format!("{:>12} {}", format!("{}:", target), record.args());
|
let msg = format!("{:>12} {}", format!("{target}:"), record.args());
|
||||||
let s = if let Some(name) = current.name() {
|
let s = if let Some(name) = current.name() {
|
||||||
format!("{:<16} {msg}", name)
|
format!("{name:<16} {msg}")
|
||||||
} else {
|
} else {
|
||||||
msg
|
msg
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -423,10 +423,7 @@ impl<S: WriteStorage + 'static, G: Signer> Simulation<S, G> {
|
||||||
self.schedule(&node, o);
|
self.schedule(&node, o);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
panic!(
|
panic!("Node {node} not found when attempting to schedule {input:?}",);
|
||||||
"Node {} not found when attempting to schedule {:?}",
|
|
||||||
node, input
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
!self.is_done()
|
!self.is_done()
|
||||||
|
|
|
||||||
|
|
@ -350,7 +350,7 @@ fn test_replication() {
|
||||||
|
|
||||||
let (seeds, results) = match alice.handle.fetch(acme).unwrap() {
|
let (seeds, results) = match alice.handle.fetch(acme).unwrap() {
|
||||||
FetchLookup::Found { seeds, results } => (seeds, results),
|
FetchLookup::Found { seeds, results } => (seeds, results),
|
||||||
other => panic!("Fetch lookup failed, got {:?}", other),
|
other => panic!("Fetch lookup failed, got {other:?}"),
|
||||||
};
|
};
|
||||||
assert_eq!(seeds, nonempty::NonEmpty::new(bob.id));
|
assert_eq!(seeds, nonempty::NonEmpty::new(bob.id));
|
||||||
|
|
||||||
|
|
@ -409,7 +409,7 @@ fn test_clone() {
|
||||||
match lookup {
|
match lookup {
|
||||||
// Drain the channel.
|
// Drain the channel.
|
||||||
FetchLookup::Found { seeds, results } => for _ in results.iter().take(seeds.len()) {},
|
FetchLookup::Found { seeds, results } => for _ in results.iter().take(seeds.len()) {},
|
||||||
other => panic!("Unexpected fetch lookup: {:?}", other),
|
other => panic!("Unexpected fetch lookup: {other:?}"),
|
||||||
}
|
}
|
||||||
rad::fork(acme, &alice.signer, &alice.storage).unwrap();
|
rad::fork(acme, &alice.signer, &alice.storage).unwrap();
|
||||||
|
|
||||||
|
|
@ -458,12 +458,12 @@ fn test_fetch_up_to_date() {
|
||||||
|
|
||||||
match alice.handle.fetch(acme).unwrap() {
|
match alice.handle.fetch(acme).unwrap() {
|
||||||
FetchLookup::Found { seeds, results } => for _ in results.iter().take(seeds.len()) {},
|
FetchLookup::Found { seeds, results } => for _ in results.iter().take(seeds.len()) {},
|
||||||
other => panic!("Unexpected fetch lookup: {:?}", other),
|
other => panic!("Unexpected fetch lookup: {other:?}"),
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch again! This time, everything's up to date.
|
// Fetch again! This time, everything's up to date.
|
||||||
match alice.handle.fetch(acme).unwrap() {
|
match alice.handle.fetch(acme).unwrap() {
|
||||||
FetchLookup::Found { seeds, results } => for _ in results.iter().take(seeds.len()) {},
|
FetchLookup::Found { seeds, results } => for _ in results.iter().take(seeds.len()) {},
|
||||||
other => panic!("Unexpected fetch lookup: {:?}", other),
|
other => panic!("Unexpected fetch lookup: {other:?}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ enum Peer {
|
||||||
impl std::fmt::Debug for Peer {
|
impl std::fmt::Debug for Peer {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
Self::Connecting { link } => write!(f, "Connecting({:?})", link),
|
Self::Connecting { link } => write!(f, "Connecting({link:?})"),
|
||||||
Self::Connected { link, id } => write!(f, "Connected({link:?}, {id})"),
|
Self::Connected { link, id } => write!(f, "Connected({link:?}, {id})"),
|
||||||
Self::Disconnected { reason, id } => write!(f, "Disconnected({reason}, {id:?})"),
|
Self::Disconnected { reason, id } => write!(f, "Disconnected({reason}, {id:?})"),
|
||||||
Self::Upgrading { fetch, link, id } => write!(
|
Self::Upgrading { fetch, link, id } => write!(
|
||||||
|
|
@ -121,7 +121,7 @@ impl Peer {
|
||||||
if let Self::Connecting { link } = self {
|
if let Self::Connecting { link } = self {
|
||||||
*self = Self::Connected { link: *link, id };
|
*self = Self::Connected { link: *link, id };
|
||||||
} else {
|
} else {
|
||||||
panic!("Peer::connected: session for {} is already established", id);
|
panic!("Peer::connected: session for {id} is already established");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -135,7 +135,7 @@ impl Peer {
|
||||||
} else if let Self::Connecting { .. } = self {
|
} else if let Self::Connecting { .. } = self {
|
||||||
*self = Self::Disconnected { id: None, reason };
|
*self = Self::Disconnected { id: None, reason };
|
||||||
} else {
|
} else {
|
||||||
panic!("Peer::disconnected: session is not connected ({:?})", self);
|
panic!("Peer::disconnected: session is not connected ({self:?})");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,13 @@ fn main() {
|
||||||
let profile = match radicle::Profile::load() {
|
let profile = match radicle::Profile::load() {
|
||||||
Ok(profile) => profile,
|
Ok(profile) => profile,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
eprintln!("fatal: couldn't load profile: {}", err);
|
eprintln!("fatal: couldn't load profile: {err}");
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Err(err) = radicle_remote_helper::run(profile) {
|
if let Err(err) = radicle_remote_helper::run(profile) {
|
||||||
eprintln!("fatal: {}", err);
|
eprintln!("fatal: {err}");
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ fn main() -> anyhow::Result<()> {
|
||||||
&profile.storage,
|
&profile.storage,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
println!("ok: {}", id);
|
println!("ok: {id}");
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ fn main() -> anyhow::Result<()> {
|
||||||
let (_, id) = radicle::rad::remote(&repo)?;
|
let (_, id) = radicle::rad::remote(&repo)?;
|
||||||
|
|
||||||
let output = radicle::git::run::<_, _, &str, &str>(&cwd, ["push", "rad"], None)?;
|
let output = radicle::git::run::<_, _, &str, &str>(&cwd, ["push", "rad"], None)?;
|
||||||
println!("{}", output);
|
println!("{output}");
|
||||||
|
|
||||||
let signer = profile.signer()?;
|
let signer = profile.signer()?;
|
||||||
let project = profile.storage.repository(id)?;
|
let project = profile.storage.repository(id)?;
|
||||||
|
|
@ -18,7 +18,7 @@ fn main() -> anyhow::Result<()> {
|
||||||
|
|
||||||
radicle::Node::new(profile.socket()).announce_refs(id)?;
|
radicle::Node::new(profile.socket()).announce_refs(id)?;
|
||||||
|
|
||||||
println!("head: {}", head);
|
println!("head: {head}");
|
||||||
println!("ok: {}", sigrefs.signature);
|
println!("ok: {}", sigrefs.signature);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
||||||
|
|
@ -428,8 +428,8 @@ pub fn set_upstream(
|
||||||
merge: &str,
|
merge: &str,
|
||||||
) -> Result<(), git2::Error> {
|
) -> Result<(), git2::Error> {
|
||||||
let mut config = repo.config()?;
|
let mut config = repo.config()?;
|
||||||
let branch_remote = format!("branch.{}.remote", branch);
|
let branch_remote = format!("branch.{branch}.remote");
|
||||||
let branch_merge = format!("branch.{}.merge", branch);
|
let branch_merge = format!("branch.{branch}.merge");
|
||||||
|
|
||||||
config.remove_multivar(&branch_remote, ".*").or_else(|e| {
|
config.remove_multivar(&branch_remote, ".*").or_else(|e| {
|
||||||
if ext::is_not_found_err(&e) {
|
if ext::is_not_found_err(&e) {
|
||||||
|
|
|
||||||
|
|
@ -164,13 +164,13 @@ mod test {
|
||||||
#[quickcheck]
|
#[quickcheck]
|
||||||
fn prop_json_eq_str(pk: PublicKey, proj: Id, did: Did) {
|
fn prop_json_eq_str(pk: PublicKey, proj: Id, did: Did) {
|
||||||
let json = serde_json::to_string(&pk).unwrap();
|
let json = serde_json::to_string(&pk).unwrap();
|
||||||
assert_eq!(format!("\"{}\"", pk), json);
|
assert_eq!(format!("\"{pk}\""), json);
|
||||||
|
|
||||||
let json = serde_json::to_string(&proj).unwrap();
|
let json = serde_json::to_string(&proj).unwrap();
|
||||||
assert_eq!(format!("\"{}\"", proj.urn()), json);
|
assert_eq!(format!("\"{}\"", proj.urn()), json);
|
||||||
|
|
||||||
let json = serde_json::to_string(&did).unwrap();
|
let json = serde_json::to_string(&did).unwrap();
|
||||||
assert_eq!(format!("\"{}\"", did), json);
|
assert_eq!(format!("\"{did}\""), json);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ impl fmt::Display for Id {
|
||||||
|
|
||||||
impl fmt::Debug for Id {
|
impl fmt::Debug for Id {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(f, "Id({})", self)
|
write!(f, "Id({self})")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -121,16 +121,16 @@ impl fmt::Display for RefUpdate {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
Self::Updated { name, old, new } => {
|
Self::Updated { name, old, new } => {
|
||||||
write!(f, "~ {:.7}..{:.7} {}", old, new, name)
|
write!(f, "~ {old:.7}..{new:.7} {name}")
|
||||||
}
|
}
|
||||||
Self::Created { name, oid } => {
|
Self::Created { name, oid } => {
|
||||||
write!(f, "* 0000000..{:.7} {}", oid, name)
|
write!(f, "* 0000000..{oid:.7} {name}")
|
||||||
}
|
}
|
||||||
Self::Deleted { name, oid } => {
|
Self::Deleted { name, oid } => {
|
||||||
write!(f, "- {:.7}..0000000 {}", oid, name)
|
write!(f, "- {oid:.7}..0000000 {name}")
|
||||||
}
|
}
|
||||||
Self::Skipped { name, oid } => {
|
Self::Skipped { name, oid } => {
|
||||||
write!(f, "= {:.7}..{:.7} {}", oid, oid, name)
|
write!(f, "= {oid:.7}..{oid:.7} {name}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -168,7 +168,7 @@ impl Storage {
|
||||||
let name = r.name().ok_or(Error::InvalidRef)?;
|
let name = r.name().ok_or(Error::InvalidRef)?;
|
||||||
let oid = r.target().ok_or(Error::InvalidRef)?;
|
let oid = r.target().ok_or(Error::InvalidRef)?;
|
||||||
|
|
||||||
println!("{} {} {}", proj.urn(), oid, name);
|
println!("{} {oid} {name}", proj.urn());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -250,7 +250,7 @@ impl Repository {
|
||||||
let name = r.name().ok_or(Error::InvalidRef)?;
|
let name = r.name().ok_or(Error::InvalidRef)?;
|
||||||
let oid = r.target().ok_or(Error::InvalidRef)?;
|
let oid = r.target().ok_or(Error::InvalidRef)?;
|
||||||
|
|
||||||
println!("{} {}", oid, name);
|
println!("{oid} {name}");
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -313,7 +313,7 @@ impl SignedRefs<Verified> {
|
||||||
Some(&sigref),
|
Some(&sigref),
|
||||||
&author,
|
&author,
|
||||||
&author,
|
&author,
|
||||||
&format!("Update signature for {}\n", remote),
|
&format!("Update signature for {remote}\n"),
|
||||||
&tree,
|
&tree,
|
||||||
&parent.iter().collect::<Vec<&git2::Commit>>(),
|
&parent.iter().collect::<Vec<&git2::Commit>>(),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
1.66
|
1.67
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue