Skip to content

Commit dc98bbf

Browse files
committed
use new color-eyre function to optionally display location section
1 parent bcbc012 commit dc98bbf

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ members = ["xtask"]
2828
[dependencies]
2929
atty = "0.2"
3030
clap = { version = "3.2.2", features = ["derive", "unstable-v4"] }
31-
color-eyre = { version = "0.6", default-features = false }
31+
color-eyre = { version = "0.6.2", default-features = false, features = ["track-caller"] }
3232
eyre = "0.6"
3333
thiserror = "1"
3434
home = "0.5"

src/docker/shared.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ pub fn get_image_name(config: &Config, target: &Target, uses_zig: bool) -> Resul
718718
);
719719
}
720720

721-
let version = if include_str!(concat!(env!("OUT_DIR"), "/commit-info.txt")).is_empty() {
721+
let version = if crate::commit_info().is_empty() {
722722
env!("CARGO_PKG_VERSION")
723723
} else {
724724
"main"
@@ -754,7 +754,7 @@ pub(crate) fn get_image(config: &Config, target: &Target, uses_zig: bool) -> Res
754754
);
755755
}
756756

757-
let version = if include_str!(concat!(env!("OUT_DIR"), "/commit-info.txt")).is_empty() {
757+
let version = if crate::commit_info().is_empty() {
758758
env!("CARGO_PKG_VERSION")
759759
} else {
760760
"main"

src/errors.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ pub use eyre::Result;
1010
pub static mut TERMINATED: AtomicBool = AtomicBool::new(false);
1111

1212
pub fn install_panic_hook() -> Result<()> {
13+
let is_dev = !crate::commit_info().is_empty() || std::env::var("CROSS_DEBUG").is_ok();
1314
color_eyre::config::HookBuilder::new()
14-
.display_env_section(false)
15+
.display_env_section(is_dev)
16+
.display_location_section(is_dev)
1517
.install()
1618
}
1719

src/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -501,10 +501,9 @@ pub fn run(
501501
msg_info: &mut MessageInfo,
502502
) -> Result<Option<ExitStatus>> {
503503
if args.version && args.subcommand.is_none() {
504-
let commit_info = include_str!(concat!(env!("OUT_DIR"), "/commit-info.txt"));
505504
msg_info.print(format_args!(
506505
concat!("cross ", env!("CARGO_PKG_VERSION"), "{}"),
507-
commit_info
506+
crate::commit_info()
508507
))?;
509508
}
510509

@@ -771,6 +770,10 @@ pub(crate) fn warn_host_version_mismatch(
771770
Ok(VersionMatch::Same)
772771
}
773772

773+
fn commit_info() -> &'static str {
774+
include_str!(concat!(env!("OUT_DIR"), "/commit-info.txt"))
775+
}
776+
774777
/// Obtains the [`CrossToml`] from one of the possible locations
775778
///
776779
/// These locations are checked in the following order:

0 commit comments

Comments
 (0)