#![allow(dead_code, unused_imports)]
use git_remote_object_store::url::{self, RemoteUrl};
pub use git_remote_object_store::test_util::{
drive_in, git, git_available, git_capture, make_seed_repo,
};
pub fn s3_url(prefix: Option<&str>) -> RemoteUrl {
s3_url_with_zip(prefix, false)
}
pub fn s3_url_with_zip(prefix: Option<&str>, zip: bool) -> RemoteUrl {
let mut raw = match prefix {
Some(p) => format!("s3+https://my-bucket.s3.us-west-2.amazonaws.com/{p}"),
None => "s3+https://my-bucket.s3.us-west-2.amazonaws.com/".to_string(),
};
if zip {
raw.push_str("?zip=1");
}
url::parse(&raw).expect("test URL must parse")
}
pub fn make_seed_repo_with_annotated_tag(
label: &str,
tag_name: &str,
) -> (tempfile::TempDir, String, String) {
let (dir, shas) = make_seed_repo(1, label);
git(
&[
"tag",
"-a",
tag_name,
"-m",
"release",
"--no-sign",
shas[0].as_str(),
],
dir.path(),
);
let tag_sha = git_capture(&["rev-parse", tag_name], dir.path())
.trim()
.to_owned();
assert_ne!(
tag_sha, shas[0],
"annotated tag must have its own object SHA",
);
(dir, shas[0].clone(), tag_sha)
}
pub fn make_seed_repo_with_tag_of_tag(
label: &str,
inner_name: &str,
outer_name: &str,
) -> (tempfile::TempDir, String, String, String) {
let (dir, shas) = make_seed_repo(1, label);
git(
&[
"tag",
"-a",
inner_name,
"-m",
"inner",
"--no-sign",
shas[0].as_str(),
],
dir.path(),
);
let inner_sha = git_capture(&["rev-parse", inner_name], dir.path())
.trim()
.to_owned();
git(
&[
"tag",
"-a",
outer_name,
"-m",
"outer",
"--no-sign",
inner_sha.as_str(),
],
dir.path(),
);
let outer_sha = git_capture(&["rev-parse", outer_name], dir.path())
.trim()
.to_owned();
assert_ne!(inner_sha, outer_sha, "outer must wrap inner");
(dir, shas[0].clone(), inner_sha, outer_sha)
}
pub fn s3_url_packchain(prefix: Option<&str>) -> RemoteUrl {
let raw = match prefix {
Some(p) => {
format!("s3+https://my-bucket.s3.us-west-2.amazonaws.com/{p}?engine=packchain")
}
None => "s3+https://my-bucket.s3.us-west-2.amazonaws.com/?engine=packchain".to_owned(),
};
url::parse(&raw).expect("packchain test URL must parse")
}