diff --git a/Cargo.lock b/Cargo.lock index 3cd698b..5cbe577 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,11 +1,5 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -[[package]] -name = "adler32" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d2e7343e7fc9de883d1b0341e0b13970f764c14101234857d2ddafa1cb1cac2" - [[package]] name = "aho-corasick" version = "0.7.10" @@ -48,8 +42,7 @@ version = "0.1.0" dependencies = [ "anyhow", "async-zlib", - "flate2", - "futures 0.3.4", + "futures", "sha-1", "structopt", "thiserror", @@ -124,16 +117,6 @@ version = "1.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" -[[package]] -name = "bytes" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" -dependencies = [ - "byteorder", - "iovec", -] - [[package]] name = "bytes" version = "0.5.4" @@ -204,15 +187,6 @@ dependencies = [ "unicode_categories", ] -[[package]] -name = "crc32fast" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" -dependencies = [ - "cfg-if", -] - [[package]] name = "crossbeam-channel" version = "0.4.2" @@ -274,7 +248,7 @@ dependencies = [ "anyhow", "async-git", "comrak", - "futures 0.3.4", + "futures", "git2", "hyper", "lazy_static", @@ -296,20 +270,6 @@ dependencies = [ name = "fedhub-hooks" version = "0.1.0" -[[package]] -name = "flate2" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cfff41391129e0a856d6d822600b8d71179d46879e310417eb9c762eb178b42" -dependencies = [ - "cfg-if", - "crc32fast", - "futures 0.1.29", - "libc", - "miniz_oxide", - "tokio-io", -] - [[package]] name = "fnv" version = "1.0.6" @@ -332,12 +292,6 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" -[[package]] -name = "futures" -version = "0.1.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b980f2816d6ee8673b6517b52cb0e808a180efc92e5c19d02cdda79066703ef" - [[package]] name = "futures" version = "0.3.4" @@ -479,7 +433,7 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "377038bf3c89d18d6ca1431e7a5027194fbd724ca10592b9487ede5e8e144f42" dependencies = [ - "bytes 0.5.4", + "bytes", "fnv", "futures-core", "futures-sink", @@ -516,7 +470,7 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28d569972648b2c512421b5f2a405ad6ac9666547189d0c5477a3f200f3e02f9" dependencies = [ - "bytes 0.5.4", + "bytes", "fnv", "itoa", ] @@ -527,7 +481,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13d5ff830006f7646652e057693569bfe0d51760c0085a071769d142a205111b" dependencies = [ - "bytes 0.5.4", + "bytes", "http", ] @@ -543,7 +497,7 @@ version = "0.13.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96816e1d921eca64d208a85aab4f7798455a8e34229ee5a88c935bdee1b78b14" dependencies = [ - "bytes 0.5.4", + "bytes", "futures-channel", "futures-core", "futures-util", @@ -725,15 +679,6 @@ version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" -[[package]] -name = "miniz_oxide" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa679ff6578b1cddee93d7e82e263b94a575e0bfced07284eb0c037c1d2416a5" -dependencies = [ - "adler32", -] - [[package]] name = "mio" version = "0.6.21" @@ -1103,7 +1048,7 @@ version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3eeb1fe3fc011cde97315f370bc88e4db3c23b08709a04915921e02b1d363b20" dependencies = [ - "bytes 0.5.4", + "bytes", "combine", "dtoa", "futures-executor", @@ -1402,7 +1347,7 @@ version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34ef16d072d2b6dc8b4a56c70f5c5ced1a37752116f8e7c1e80c659aa7cb6713" dependencies = [ - "bytes 0.5.4", + "bytes", "fnv", "futures-core", "iovec", @@ -1420,17 +1365,6 @@ dependencies = [ "winapi 0.3.8", ] -[[package]] -name = "tokio-io" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57fc868aae093479e3131e3d165c93b1c7474109d13c90ec0dda2a1bbfff0674" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.29", - "log", -] - [[package]] name = "tokio-macros" version = "0.2.5" @@ -1448,7 +1382,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "571da51182ec208780505a32528fc5512a8fe1443ab960b3f2f3ef093cd16930" dependencies = [ - "bytes 0.5.4", + "bytes", "futures-core", "futures-sink", "log", @@ -1462,7 +1396,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499" dependencies = [ - "bytes 0.5.4", + "bytes", "futures-core", "futures-sink", "log", diff --git a/async-git/Cargo.toml b/async-git/Cargo.toml index f9016cd..d1390f8 100644 --- a/async-git/Cargo.toml +++ b/async-git/Cargo.toml @@ -16,5 +16,4 @@ anyhow = { version = "1.0.28", default-features = false } thiserror = { version = "1.0.15", default-features = false } futures = { version = "0.3.4", default-features = false } sha-1 = { version = "0.8.2", default-features = false } -flate2 = { version = "1.0.14", features = ["tokio"] } async-zlib = { path = "../async-zlib" } \ No newline at end of file diff --git a/async-git/src/plumbing/commit.rs b/async-git/src/plumbing/commit.rs index e8e4e23..7e6b6c7 100644 --- a/async-git/src/plumbing/commit.rs +++ b/async-git/src/plumbing/commit.rs @@ -1,9 +1,9 @@ use std::io::Error as IOError; -use tokio::io::{AsyncWrite, AsyncRead}; +use tokio::io::{AsyncRead, AsyncWrite}; -use crate::util::ZlibIO; use crate::plumbing::Oid; +use crate::util::ZlibIO; #[derive(Clone)] pub struct Commit { diff --git a/async-git/src/plumbing/object.rs b/async-git/src/plumbing/object.rs index 221d75f..566c27c 100644 --- a/async-git/src/plumbing/object.rs +++ b/async-git/src/plumbing/object.rs @@ -1,16 +1,15 @@ -use std::fs::File; use std::path::PathBuf; use std::pin::Pin; use std::str::FromStr; use std::task::{Context, Poll}; use anyhow::Error; -use flate2::read::ZlibDecoder; -use tokio::io::{AsyncReadExt}; +use async_zlib::ZlibDecoder; +use tokio::{io::AsyncReadExt, fs::File}; use typenum::U19; use crate::plumbing::Commit; -use crate::util::{ZlibIO, self}; +use crate::util::{self, ZlibIO}; pub struct Object { repo_path: PathBuf, @@ -25,15 +24,17 @@ impl Object { } pub async fn peel(&self) -> Result { - let file = File::open(self.get_path_on_disk())?; - let r = ZlibDecoder::new(file); + let file = File::open(self.get_path_on_disk()).await?; + let mut r = ZlibDecoder::new(file); // we're going to determine the type of object based on the first character let c = r.read_u8().await?; + + unimplemented!() } } -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct Oid([u8; 20]); impl FromStr for Oid { diff --git a/async-git/src/porcelain/log.rs b/async-git/src/porcelain/log.rs index 3fa6547..a16752f 100644 --- a/async-git/src/porcelain/log.rs +++ b/async-git/src/porcelain/log.rs @@ -1,8 +1,12 @@ +use anyhow::Result; + use crate::plumbing::Oid; -#[derive(StructOpt)] +#[derive(Debug, StructOpt)] pub struct LogOptions { commit: Oid, } -pub async fn log_cmd(options: LogOptions) {} +pub async fn log_cmd(options: LogOptions) -> Result<()> { + Ok(()) +} diff --git a/async-git/src/porcelain/mod.rs b/async-git/src/porcelain/mod.rs index febd503..a7f7d5f 100644 --- a/async-git/src/porcelain/mod.rs +++ b/async-git/src/porcelain/mod.rs @@ -1,7 +1,7 @@ mod init; -mod show; mod log; +mod show; pub use self::init::{init_cmd, InitOptions}; -pub use self::show::{show_cmd, ShowOptions}; pub use self::log::{log_cmd, LogOptions}; +pub use self::show::{show_cmd, ShowOptions}; diff --git a/async-git/src/porcelain/show.rs b/async-git/src/porcelain/show.rs index 509b367..3396f0e 100644 --- a/async-git/src/porcelain/show.rs +++ b/async-git/src/porcelain/show.rs @@ -1,6 +1,6 @@ use crate::plumbing::Oid; -#[derive(StructOpt)] +#[derive(Debug, StructOpt)] pub struct ShowOptions { /// The names of objects to show (defaults to HEAD). objects: Vec, @@ -9,7 +9,5 @@ pub struct ShowOptions { pub async fn show_cmd(options: ShowOptions) { let mut objects = options.objects; - for id in objects { - - } + for id in objects {} } diff --git a/async-git/src/util.rs b/async-git/src/util.rs index a58e20e..2455c80 100644 --- a/async-git/src/util.rs +++ b/async-git/src/util.rs @@ -1,8 +1,8 @@ use std::io; use std::path::Path; +use async_zlib::{ZlibDecoder, ZlibEncoder}; use tokio::{fs::File, io::AsyncWriteExt}; -use flate2::read::ZlibDecoder; use typenum::Unsigned; /// Marker trait to ensure compression/decompression is already happening transparently. @@ -10,6 +10,8 @@ pub trait ZlibIO {} impl ZlibIO for ZlibDecoder {} +impl ZlibIO for ZlibEncoder {} + #[inline] fn hexchar(b: u8) -> [u8; 2] { let a = b >> 4; diff --git a/async-zlib/src/decoder.rs b/async-zlib/src/decoder.rs index aeb8c42..da1855f 100644 --- a/async-zlib/src/decoder.rs +++ b/async-zlib/src/decoder.rs @@ -1 +1,23 @@ +use std::io::Error as IOError; +use std::pin::Pin; +use std::task::{Context, Poll}; + +use tokio::io::AsyncRead; + pub struct ZlibDecoder(R); + +impl ZlibDecoder { + pub fn new(r: R) -> Self { + ZlibDecoder(r) + } +} + +impl AsyncRead for ZlibDecoder { + fn poll_read( + self: Pin<&mut Self>, + ctx: &mut Context<'_>, + buf: &mut [u8], + ) -> Poll> { + todo!() + } +}