Skip to content

Commit 1dfa90d

Browse files
committed
Merge branch 'tar-only'
2 parents f6eaba3 + dcab79a commit 1dfa90d

File tree

203 files changed

+93
-47
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

203 files changed

+93
-47
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
basic.tar.xz
1+
basic.tar
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
make_attributes_baseline.tar.xz
1+
make_attributes_baseline.tar
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
win_path_lookup.tar.xz
1+
win_path_lookup.tar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
/make_config_repo.tar.xz
1+
/make_config_repo.tar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
many.tar.xz
2-
many-symlinks.tar.xz
1+
many.tar
2+
many-symlinks.tar
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
/make_basic_repo.tar.xz
1+
/make_basic_repo.tar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
/baseline.tar.xz
1+
/baseline.tar
Binary file not shown.
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
make_test_repos.tar.xz
1+
make_test_repos.tar
Binary file not shown.
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
make_global_and_external_and_dir_ignores.tar.xz
1+
make_global_and_external_and_dir_ignores.tar
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
file_metadata.tar.xz
1+
file_metadata.tar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
repo_with_loose_objects.tar.xz
2-
make_alternates_odb.tar.xz
1+
repo_with_loose_objects.tar
2+
make_alternates_odb.tar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
make_worktree_repo.tar.xz
1+
make_worktree_repo.tar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
/match_baseline.tar.xz
1+
/match_baseline.tar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
status_unchanged.tar.xz
2-
status_changed.tar.xz
3-
symlink_stack.tar.xz
1+
status_unchanged.tar
2+
status_changed.tar
3+
symlink_stack.tar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
make_baseline.tar.xz
1+
make_baseline.tar
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
make_ignore_and_attributes_setup.tar.xz
2-
make_mixed_without_submodules.tar.xz
3-
make_mixed.tar.xz
4-
make_mixed_without_submodules_and_symlinks.tar.xz
5-
make_attributes_baseline.tar.xz
6-
make_dangerous_symlink.tar.xz
7-
make_ignorecase_collisions.tar.xz
1+
make_ignore_and_attributes_setup.tar
2+
make_mixed_without_submodules.tar
3+
make_mixed.tar
4+
make_mixed_without_submodules_and_symlinks.tar
5+
make_attributes_baseline.tar
6+
make_dangerous_symlink.tar
7+
make_ignorecase_collisions.tar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
basic.tar.xz
1+
basic.tar
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
make_ignore_and_attributes_setup.tar.xz
2-
make_attributes_baseline.tar.xz
3-
symlink_stack.tar.xz
1+
make_ignore_and_attributes_setup.tar
2+
make_attributes_baseline.tar
3+
symlink_stack.tar
Binary file not shown.
Binary file not shown.
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
/make_worktree_repo.tar.xz
2-
/make_worktree_repo_with_configs.tar.xz
3-
/make_remote_repos.tar.xz
4-
/make_complex_shallow_repo.tar.xz
5-
/make_fetch_repos.tar.xz
6-
/make_core_worktree_repo.tar.xz
7-
/make_signatures_repo.tar.xz
1+
/make_worktree_repo.tar
2+
/make_worktree_repo_with_configs.tar
3+
/make_remote_repos.tar
4+
/make_complex_shallow_repo.tar
5+
/make_fetch_repos.tar
6+
/make_core_worktree_repo.tar
7+
/make_signatures_repo.tar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

justfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ doc $RUSTDOCFLAGS="-D warnings":
153153
# run all unit tests
154154
unit-tests:
155155
cargo test --all
156+
cargo test -p gix-testtools
157+
cargo test -p gix-testtools --features xz
156158
cargo test -p gix-archive --no-default-features
157159
cargo test -p gix-archive --features tar
158160
cargo test -p gix-archive --features tar_gz

tests/tools/Cargo.toml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ path = "src/main.rs"
1414
[lib]
1515
doctest = false
1616

17+
[features]
18+
default = []
19+
## Use instead of plain `tar` files, compress these to produce `tar.xz` files instead.
20+
## This is useful if archives are uploaded into `git-lfs`, which doesn't have built-in compression
21+
## and metering counts towards uncompressed bytes transferred.
22+
xz = ["dep:xz2"]
23+
1724
[dependencies]
1825
gix-lock = "14.0.0"
1926
gix-discover = "0.32.0"
@@ -35,4 +42,10 @@ parking_lot = { version = "0.12.0" }
3542
is_ci = "1.1.1"
3643
io-close = "0.3.7"
3744
tar = { version = "0.4.38", default-features = false }
38-
xz2 = "0.1.6"
45+
xz2 = { version = "0.1.6", optional = true }
46+
47+
document-features = { version = "0.2.1", optional = true }
48+
49+
[package.metadata.docs.rs]
50+
all-features = true
51+
features = ["document-features"]

tests/tools/src/lib.rs

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
//! Utilities for testing `gitoxide` crates, many of which might be useful for testing programs that use `git` in general.
2+
//!
3+
//! ## Feature Flags
4+
#![cfg_attr(
5+
all(doc, feature = "document-features"),
6+
doc = ::document_features::document_features!()
7+
)]
8+
#![cfg_attr(all(doc, feature = "document-features"), feature(doc_cfg, doc_auto_cfg))]
29
#![deny(missing_docs)]
310

411
use std::{
@@ -269,7 +276,7 @@ fn fixture_bytes_inner(path: impl AsRef<Path>, root: DirectoryRoot) -> Vec<u8> {
269276
/// #### Disable Archive Creation
270277
///
271278
/// If archives aren't useful, they can be disabled by using `.gitignore` specifications.
272-
/// That way it's trivial to prevent creation of all archives with `generated-archives/*.tar.xz` in the root
279+
/// That way it's trivial to prevent creation of all archives with `generated-archives/*.tar{.xz}` in the root
273280
/// or more specific `.gitignore` configurations in lower levels of the work tree.
274281
///
275282
/// The latter is useful if the script's output is platform specific.
@@ -407,7 +414,11 @@ fn scripted_fixture_read_only_with_args_inner(
407414

408415
let script_basename = script_location.file_stem().unwrap_or(script_location.as_os_str());
409416
let archive_file_path = fixture_path_inner(
410-
Path::new("generated-archives").join(format!("{}.tar.xz", script_basename.to_str().expect("valid UTF-8"))),
417+
Path::new("generated-archives").join(format!(
418+
"{}.tar{}",
419+
script_basename.to_str().expect("valid UTF-8"),
420+
if cfg!(feature = "xz") { ".xz" } else { "" }
421+
)),
411422
root,
412423
);
413424
let (force_run, script_result_directory) = destination_dir.map_or_else(
@@ -566,14 +577,24 @@ fn create_archive_if_not_on_ci(source_dir: &Path, archive: &Path, script_identit
566577
ar.append_dir_all(".", source_dir)?;
567578
ar.finish()?;
568579
}
569-
let archive = std::fs::OpenOptions::new()
580+
#[cfg_attr(feature = "xz", allow(unused_mut))]
581+
let mut archive = std::fs::OpenOptions::new()
570582
.write(true)
571583
.create(true)
572584
.truncate(true)
573585
.open(archive)?;
574-
let mut xz_write = xz2::write::XzEncoder::new(archive, 3);
575-
std::io::copy(&mut &*buf, &mut xz_write)?;
576-
xz_write.finish()?.close()
586+
#[cfg(feature = "xz")]
587+
{
588+
let mut xz_write = xz2::write::XzEncoder::new(archive, 3);
589+
std::io::copy(&mut &*buf, &mut xz_write)?;
590+
xz_write.finish()?.close()
591+
}
592+
#[cfg(not(feature = "xz"))]
593+
{
594+
use std::io::Write;
595+
archive.write_all(&buf)?;
596+
archive.close()
597+
}
577598
})();
578599
#[cfg(not(windows))]
579600
std::fs::remove_dir_all(meta_dir)?;
@@ -629,7 +650,8 @@ fn extract_archive(
629650
) -> std::io::Result<(u32, Option<String>)> {
630651
let archive_buf: Vec<u8> = {
631652
let mut buf = Vec::new();
632-
let input_archive = std::fs::File::open(archive)?;
653+
#[cfg_attr(feature = "xz", allow(unused_mut))]
654+
let mut input_archive = std::fs::File::open(archive)?;
633655
if std::env::var_os("GIX_TEST_IGNORE_ARCHIVES").is_some() {
634656
return Err(std::io::Error::new(
635657
std::io::ErrorKind::Other,
@@ -639,8 +661,16 @@ fn extract_archive(
639661
),
640662
));
641663
}
642-
let mut decoder = xz2::bufread::XzDecoder::new(std::io::BufReader::new(input_archive));
643-
std::io::copy(&mut decoder, &mut buf)?;
664+
#[cfg(feature = "xz")]
665+
{
666+
let mut decoder = xz2::bufread::XzDecoder::new(std::io::BufReader::new(input_archive));
667+
std::io::copy(&mut decoder, &mut buf)?;
668+
}
669+
#[cfg(not(feature = "xz"))]
670+
{
671+
use std::io::Read;
672+
input_archive.read_to_end(&mut buf)?;
673+
}
644674
buf
645675
};
646676

0 commit comments

Comments
 (0)