mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-12 23:23:20 +00:00
style: inline variables into format strings
This commit is contained in:
parent
62f582e6ab
commit
46e2723464
14 changed files with 25 additions and 28 deletions
|
@ -134,7 +134,8 @@ testutils = { path = "lib/testutils" }
|
|||
|
||||
[workspace.lints.clippy]
|
||||
explicit_iter_loop = "warn"
|
||||
|
||||
uninlined_format_args = "warn"
|
||||
|
||||
# Insta suggests compiling these packages in opt mode for faster testing.
|
||||
# See https://docs.rs/insta/latest/insta/#optional-faster-runs.
|
||||
[profile.dev.package]
|
||||
|
|
|
@ -33,9 +33,9 @@ fn main() {
|
|||
println!("cargo:rerun-if-env-changed=NIX_JJ_GIT_HASH");
|
||||
|
||||
if let Some(git_hash) = get_git_hash() {
|
||||
println!("cargo:rustc-env=JJ_VERSION={}-{}", version, git_hash);
|
||||
println!("cargo:rustc-env=JJ_VERSION={version}-{git_hash}");
|
||||
} else {
|
||||
println!("cargo:rustc-env=JJ_VERSION={}", version);
|
||||
println!("cargo:rustc-env=JJ_VERSION={version}");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3314,7 +3314,7 @@ impl CliRunner {
|
|||
.flatten()
|
||||
.map(|path| format!("- {}", path.display()))
|
||||
.join("\n");
|
||||
e.hinted(format!("Check the following config files:\n{}", paths))
|
||||
e.hinted(format!("Check the following config files:\n{paths}"))
|
||||
})?;
|
||||
|
||||
let string_args = expand_args(ui, &self.app, env::args_os(), &config)?;
|
||||
|
|
|
@ -352,7 +352,7 @@ impl From<SnapshotError> for CommandError {
|
|||
size_diff, max_size.0, max_size,
|
||||
)
|
||||
} else {
|
||||
format!("it is {}; the maximum size allowed is ~{}.", size, max_size,)
|
||||
format!("it is {size}; the maximum size allowed is ~{max_size}.")
|
||||
};
|
||||
|
||||
user_error(format!(
|
||||
|
|
|
@ -123,7 +123,7 @@ pub struct GitPushArgs {
|
|||
|
||||
fn make_bookmark_term(bookmark_names: &[impl fmt::Display]) -> String {
|
||||
match bookmark_names {
|
||||
[bookmark_name] => format!("bookmark {}", bookmark_name),
|
||||
[bookmark_name] => format!("bookmark {bookmark_name}"),
|
||||
bookmark_names => format!("bookmarks {}", bookmark_names.iter().join(", ")),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -282,7 +282,7 @@ pub fn show_op_diff(
|
|||
})?;
|
||||
for (name, (from_target, to_target)) in changed_local_bookmarks {
|
||||
with_content_format.write(formatter, |formatter| {
|
||||
writeln!(formatter, "{}:", name)?;
|
||||
writeln!(formatter, "{name}:")?;
|
||||
write_ref_target_summary(
|
||||
formatter,
|
||||
current_repo,
|
||||
|
@ -310,7 +310,7 @@ pub fn show_op_diff(
|
|||
with_content_format.write(formatter, |formatter| writeln!(formatter, "Changed tags:"))?;
|
||||
for (name, (from_target, to_target)) in changed_tags {
|
||||
with_content_format.write(formatter, |formatter| {
|
||||
writeln!(formatter, "{}:", name)?;
|
||||
writeln!(formatter, "{name}:")?;
|
||||
write_ref_target_summary(
|
||||
formatter,
|
||||
current_repo,
|
||||
|
@ -351,7 +351,7 @@ pub fn show_op_diff(
|
|||
};
|
||||
for ((name, remote_name), (from_ref, to_ref)) in changed_remote_bookmarks {
|
||||
with_content_format.write(formatter, |formatter| {
|
||||
writeln!(formatter, "{}@{}:", name, remote_name)?;
|
||||
writeln!(formatter, "{name}@{remote_name}:")?;
|
||||
write_ref_target_summary(
|
||||
formatter,
|
||||
current_repo,
|
||||
|
@ -422,7 +422,7 @@ fn write_ref_target_summary(
|
|||
})?;
|
||||
write!(formatter, " ")?;
|
||||
if let Some(prefix) = prefix {
|
||||
write!(formatter, "{} ", prefix)?;
|
||||
write!(formatter, "{prefix} ")?;
|
||||
}
|
||||
Ok(())
|
||||
};
|
||||
|
|
|
@ -177,7 +177,7 @@ fn edit_sparse(
|
|||
workspace_relative_sparse_path.display()
|
||||
))
|
||||
})?;
|
||||
writeln!(&mut content, "{}", path_string).unwrap();
|
||||
writeln!(&mut content, "{path_string}").unwrap();
|
||||
}
|
||||
|
||||
let content = edit_temp_file(
|
||||
|
|
|
@ -39,10 +39,9 @@ pub fn edit_description(
|
|||
settings: &UserSettings,
|
||||
) -> Result<String, CommandError> {
|
||||
let description = format!(
|
||||
r#"{}
|
||||
r#"{description}
|
||||
JJ: Lines starting with "JJ: " (like this one) will be removed.
|
||||
"#,
|
||||
description
|
||||
"#
|
||||
);
|
||||
|
||||
let description = edit_temp_file(
|
||||
|
|
|
@ -395,7 +395,7 @@ impl<W: Write> ColorFormatter<W> {
|
|||
}
|
||||
if let Some(d) = new_debug {
|
||||
if !d.is_empty() {
|
||||
write!(self.output, "<<{}::", d)?;
|
||||
write!(self.output, "<<{d}::")?;
|
||||
}
|
||||
self.current_debug = Some(d);
|
||||
}
|
||||
|
@ -471,7 +471,7 @@ fn color_for_name_or_hex(name_or_hex: &str) -> Result<Color, config::ConfigError
|
|||
"bright cyan" => Ok(Color::Cyan),
|
||||
"bright white" => Ok(Color::White),
|
||||
_ => color_for_hex(name_or_hex)
|
||||
.ok_or_else(|| config::ConfigError::Message(format!("invalid color: {}", name_or_hex))),
|
||||
.ok_or_else(|| config::ConfigError::Message(format!("invalid color: {name_or_hex}"))),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -786,7 +786,7 @@ mod tests {
|
|||
for [label, color] in labels_and_colors {
|
||||
// Use the color name as the label.
|
||||
config_builder = config_builder
|
||||
.set_override(format!("colors.{}", label), color)
|
||||
.set_override(format!("colors.{label}"), color)
|
||||
.unwrap();
|
||||
}
|
||||
let mut output: Vec<u8> = vec![];
|
||||
|
|
|
@ -632,7 +632,7 @@ impl Ui {
|
|||
let default_choice = default.map(|c| if c { "Y" } else { "N" });
|
||||
|
||||
let choice = self.prompt_choice(
|
||||
&format!("{} {}", prompt, default_str),
|
||||
&format!("{prompt} {default_str}"),
|
||||
&["y", "n", "yes", "no", "Yes", "No", "YES", "NO"],
|
||||
default_choice,
|
||||
)?;
|
||||
|
|
|
@ -70,7 +70,7 @@ fn main() -> ExitCode {
|
|||
let args: Args = Args::parse();
|
||||
// Code formatters tend to print errors before printing the result.
|
||||
if let Some(data) = args.stderr {
|
||||
eprint!("{}", data);
|
||||
eprint!("{data}");
|
||||
}
|
||||
let stdout = if let Some(data) = args.stdout {
|
||||
// Other content-altering flags don't apply to --stdout.
|
||||
|
@ -106,14 +106,14 @@ fn main() -> ExitCode {
|
|||
}
|
||||
stdout
|
||||
};
|
||||
print!("{}", stdout);
|
||||
print!("{stdout}");
|
||||
if let Some(path) = args.tee {
|
||||
let mut file = OpenOptions::new()
|
||||
.create(true)
|
||||
.append(true)
|
||||
.open(path)
|
||||
.unwrap();
|
||||
write!(file, "{}", stdout).unwrap();
|
||||
write!(file, "{stdout}").unwrap();
|
||||
}
|
||||
if args.fail {
|
||||
ExitCode::FAILURE
|
||||
|
|
|
@ -433,8 +433,8 @@ fn test_diff_types() {
|
|||
&[
|
||||
"diff",
|
||||
"--types",
|
||||
&format!(r#"--from=description("{}")"#, from),
|
||||
&format!(r#"--to=description("{}")"#, to),
|
||||
&format!(r#"--from=description("{from}")"#),
|
||||
&format!(r#"--to=description("{to}")"#),
|
||||
],
|
||||
)
|
||||
};
|
||||
|
|
|
@ -354,10 +354,7 @@ impl IndexStore for DefaultIndexStore {
|
|||
);
|
||||
}
|
||||
ReadonlyIndexLoadError::Other { name: _, error } => {
|
||||
eprintln!(
|
||||
"{err} (maybe the format has changed): {source}. Reindexing...",
|
||||
source = error
|
||||
);
|
||||
eprintln!("{err} (maybe the format has changed): {error}. Reindexing...");
|
||||
}
|
||||
}
|
||||
self.reinit().map_err(|err| IndexReadError(err.into()))?;
|
||||
|
|
|
@ -762,7 +762,7 @@ impl RepoLoader {
|
|||
tx.repo_mut().rebase_descendants(settings)?;
|
||||
}
|
||||
let tx_description = tx_description.map_or_else(
|
||||
|| format!("merge {} operations", num_operations),
|
||||
|| format!("merge {num_operations} operations"),
|
||||
|tx_description| tx_description.to_string(),
|
||||
);
|
||||
let merged_repo = tx.write(tx_description).leave_unpublished();
|
||||
|
|
Loading…
Reference in a new issue