Integrate the ignored-workspace corpus into verification

Give the Git Sentry launch shape one Rust owner, update the physical corpus to supply every authority, and make the default repository gate distinguish unavailable physical prerequisites from corpus failures.
This commit is contained in:
ms2k 2026-07-19 02:39:45 +09:00
commit a0055f67f1

View file

@ -1,3 +1,4 @@
use std::ffi::OsString;
use std::fs::File;
use std::io;
use std::path::{Path, PathBuf};
@ -18,6 +19,53 @@ pub struct GitSentryConfiguration {
pub transient_config: PathBuf,
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct GitSentryLaunch {
arguments: [PathBuf; 4],
}
impl GitSentryLaunch {
#[must_use]
pub fn new(configuration: GitSentryConfiguration) -> Self {
Self {
arguments: [
configuration.mounted_workspace,
configuration.host_git_common_directory,
configuration.transient_hooks,
configuration.transient_config,
],
}
}
/// # Errors
/// Refuses any argument count other than the exact Git Sentry launch shape.
pub fn parse(arguments: Vec<OsString>) -> io::Result<Self> {
let arguments: [OsString; 4] = arguments.try_into().map_err(|_| {
io::Error::other(
"usage: lazaret-git-sentry MOUNTED_WORKSPACE HOST_GIT_COMMON_DIRECTORY TRANSIENT_HOOKS TRANSIENT_CONFIG",
)
})?;
Ok(Self {
arguments: arguments.map(PathBuf::from),
})
}
#[must_use]
pub fn configuration(&self) -> GitSentryConfiguration {
GitSentryConfiguration {
mounted_workspace: self.arguments[0].clone(),
host_git_common_directory: self.arguments[1].clone(),
transient_hooks: self.arguments[2].clone(),
transient_config: self.arguments[3].clone(),
}
}
#[must_use]
pub fn arguments(&self) -> [OsString; 4] {
self.arguments.clone().map(PathBuf::into_os_string)
}
}
pub struct GitSentry {
config: InstalledMount,
hooks: InstalledMount,
@ -266,3 +314,42 @@ fn require_regular_file(file: &File) -> io::Result<()> {
Err(io::Error::other("host Git config is not a regular file"))
}
}
#[cfg(test)]
mod tests {
use std::ffi::OsString;
use std::path::PathBuf;
use super::{GitSentryConfiguration, GitSentryLaunch};
fn configuration() -> GitSentryConfiguration {
GitSentryConfiguration {
mounted_workspace: PathBuf::from("/workspace"),
host_git_common_directory: PathBuf::from("/host/.git"),
transient_hooks: PathBuf::from("/transient/hooks"),
transient_config: PathBuf::from("/transient/config"),
}
}
#[test]
fn launch_arguments_round_trip_through_the_binary_parser() {
let launch = GitSentryLaunch::new(configuration());
let parsed = GitSentryLaunch::parse(launch.arguments().into()).unwrap();
assert_eq!(parsed, launch);
assert_eq!(
parsed.configuration().transient_config,
PathBuf::from("/transient/config")
);
}
#[test]
fn launch_parser_requires_every_ordered_authority() {
for count in [0, 1, 2, 3, 5] {
let arguments = (0..count)
.map(|index| OsString::from(format!("/{index}")))
.collect();
assert!(GitSentryLaunch::parse(arguments).is_err());
}
}
}