Skip to content

Commit

Permalink
use new color-eyre function to optionally display location section
Browse files Browse the repository at this point in the history
  • Loading branch information
Emilgardis committed Jul 23, 2022
1 parent bcbc012 commit dc98bbf
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ members = ["xtask"]
[dependencies]
atty = "0.2"
clap = { version = "3.2.2", features = ["derive", "unstable-v4"] }
color-eyre = { version = "0.6", default-features = false }
color-eyre = { version = "0.6.2", default-features = false, features = ["track-caller"] }
eyre = "0.6"
thiserror = "1"
home = "0.5"
Expand Down
4 changes: 2 additions & 2 deletions src/docker/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ pub fn get_image_name(config: &Config, target: &Target, uses_zig: bool) -> Resul
);
}

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

let version = if include_str!(concat!(env!("OUT_DIR"), "/commit-info.txt")).is_empty() {
let version = if crate::commit_info().is_empty() {
env!("CARGO_PKG_VERSION")
} else {
"main"
Expand Down
4 changes: 3 additions & 1 deletion src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ pub use eyre::Result;
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(false)
.display_env_section(is_dev)
.display_location_section(is_dev)
.install()
}

Expand Down
7 changes: 5 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,10 +501,9 @@ pub fn run(
msg_info: &mut MessageInfo,
) -> Result<Option<ExitStatus>> {
if args.version && args.subcommand.is_none() {
let commit_info = include_str!(concat!(env!("OUT_DIR"), "/commit-info.txt"));
msg_info.print(format_args!(
concat!("cross ", env!("CARGO_PKG_VERSION"), "{}"),
commit_info
crate::commit_info()
))?;
}

Expand Down Expand Up @@ -771,6 +770,10 @@ pub(crate) fn warn_host_version_mismatch(
Ok(VersionMatch::Same)
}

fn commit_info() -> &'static str {
include_str!(concat!(env!("OUT_DIR"), "/commit-info.txt"))
}

/// Obtains the [`CrossToml`] from one of the possible locations
///
/// These locations are checked in the following order:
Expand Down

0 comments on commit dc98bbf

Please sign in to comment.