hive-c0re: validate forge env at startup; char-safe short revs
HIVE_FORGE_URL (set + parseable) and HIVE_ASSETS_DIR are checked once in main before workers start. Short revs in container_view and pr_status take 12 chars instead of byte-slicing.
This commit is contained in:
parent
9b711d5ffa
commit
6bb13f964d
4 changed files with 56 additions and 6 deletions
|
|
@ -263,9 +263,15 @@ fn status_mark(status: &str) -> &'static str {
|
|||
}
|
||||
}
|
||||
|
||||
/// First 12 characters of a sha. Counts chars, not bytes, so a multi-byte
|
||||
/// char at the cut cannot panic.
|
||||
fn short_sha(sha: &str) -> String {
|
||||
sha.chars().take(12).collect()
|
||||
}
|
||||
|
||||
/// Render the CI section (overall verdict + per-context rows).
|
||||
fn print_ci(sha: &str, state: &str, statuses: &[Value]) {
|
||||
let short = &sha[..sha.len().min(12)];
|
||||
let short = short_sha(sha);
|
||||
if statuses.is_empty() {
|
||||
println!("{short}: no CI statuses reported (CI may not have started)");
|
||||
return;
|
||||
|
|
@ -462,12 +468,17 @@ mod tests {
|
|||
#[test]
|
||||
fn short_sha_truncates() {
|
||||
let sha = "0123456789abcdef0123456789abcdef";
|
||||
assert_eq!(&sha[..sha.len().min(12)], "0123456789ab");
|
||||
assert_eq!(short_sha(sha), "0123456789ab");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn short_sha_handles_already_short() {
|
||||
assert_eq!(&"abc123"[.."abc123".len().min(12)], "abc123");
|
||||
assert_eq!(short_sha("abc123"), "abc123");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn short_sha_survives_multibyte_at_boundary() {
|
||||
assert_eq!(short_sha("0123456789aébcdef"), "0123456789aé");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
Loading…
Reference in a new issue