Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

some xtask changes #1414

Merged
merged 8 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ jobs:
for path in "${added_modified[@]}"; do
basenames+=($(basename "${path}"))
done
cargo xtask validate-changelog "${basenames[@]}"
cargo xtask changelog validate "${basenames[@]}"
fi
fi
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
- uses: ./.github/actions/setup-rust
with:
components: clippy
toolchain: 1.64.0 # MSRV, Minimally Supported Rust Version. Make sure to update README.md
toolchain: 1.64.0 # MSRV, Minimally Supported Rust Version. Make sure to update README.md and clippy.toml
- name: Run clippy
run: cargo clippy --locked --all-targets --all-features --workspace -- -D warnings
test:
Expand Down
49 changes: 19 additions & 30 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ ignore = "0.4.20"
push = false
publish = false
tag = false
pre-release-hook = ["cargo", "xtask", "build-changelog"]
consolidate-commits = false
pre-release-hook = ["cargo", "xtask", "changelog", "build", "--release", "{{version}}"]
pre-release-commit-message = "release version {{version}}"

[[package.metadata.release.pre-release-replacements]]
Expand Down
1 change: 1 addition & 0 deletions clippy.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ disallowed-methods = [
{ path = "std::path::Path::display", reason = "incorrect handling of non-Unicode paths, use path.to_utf8() or debug (`{path:?}`) instead" },
]
allow-unwrap-in-tests = true
msrv = "1.64.0"
6 changes: 3 additions & 3 deletions src/docker/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl PossibleImage {
}
} else {
let platform = if self.toolchain.len() == 1 {
self.toolchain.get(0).expect("should contain at least one")
self.toolchain.first().expect("should contain at least one")
} else {
let same_arch = self
.toolchain
Expand All @@ -48,7 +48,7 @@ impl PossibleImage {

if same_arch.len() == 1 {
// pick the platform with the same architecture
same_arch.get(0).expect("should contain one element")
same_arch.first().expect("should contain one element")
} else if let Some(platform) = same_arch
.iter()
.find(|platform| &platform.os == engine.os.as_ref().unwrap_or(&Os::Linux))
Expand All @@ -62,7 +62,7 @@ impl PossibleImage {
} else {
let platform = self
.toolchain
.get(0)
.first()
.expect("should be at least one platform");
// FIXME: Don't throw away
msg_info.warn(
Expand Down
4 changes: 2 additions & 2 deletions src/docker/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1278,7 +1278,7 @@ pub fn get_image_name(
};

Ok(compatible
.get(0)
.first()
.expect("should not be empty")
.image_name(CROSS_IMAGE, version))
}
Expand Down Expand Up @@ -1316,7 +1316,7 @@ pub fn get_image(

let pick = if compatible.len() == 1 {
// If only one match, use that
compatible.get(0).expect("should not be empty")
compatible.first().expect("should not be empty")
} else if compatible
.iter()
.filter(|provided| provided.sub.is_none())
Expand Down
2 changes: 1 addition & 1 deletion src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub static mut TERMINATED: AtomicBool = AtomicBool::new(false);
pub fn install_panic_hook() -> Result<()> {
let is_dev = !crate::commit_info().is_empty() || std::env::var("CROSS_DEBUG").is_ok();
color_eyre::config::HookBuilder::new()
.display_env_section(is_dev)
.display_env_section(false)
.display_location_section(is_dev)
.install()
}
Expand Down
9 changes: 5 additions & 4 deletions src/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,9 @@ pub fn default_ident() -> usize {

#[must_use]
pub fn indent(message: &str, spaces: usize) -> String {
message
.lines()
.map(|s| format!("{:spaces$}{s}", ""))
.collect()
use std::fmt::Write as _;
message.lines().fold(String::new(), |mut string, line| {
let _ = write!(string, "{:spaces$}{line}", "");
string
})
}
8 changes: 4 additions & 4 deletions xtask/src/build_docker_image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,10 +342,10 @@ pub fn build_docker_image(
}
if results.iter().any(|r| r.is_err()) {
#[allow(unknown_lints, clippy::manual_try_fold)]
results
.into_iter()
.filter_map(Result::err)
.fold(Err(eyre::eyre!("encountered error(s)")), |_, e| Err(e.1))?;
return Err(crate::util::with_section_reports(
eyre::eyre!("some error(s) encountered"),
results.into_iter().filter_map(Result::err).map(|e| e.1),
));
}
Ok(())
}
Expand Down
Loading
Loading