restructure
This commit is contained in:
parent
2251c4f8ea
commit
050d8afdf9
20 changed files with 133 additions and 73 deletions
45
Cargo.lock
generated
45
Cargo.lock
generated
|
@ -17,9 +17,9 @@ checksum = "d9a60d744a80c30fcb657dfe2c1b22bcb3e814c1a1e3674f32bf5820b570fbff"
|
|||
|
||||
[[package]]
|
||||
name = "arc-swap"
|
||||
version = "0.4.5"
|
||||
version = "0.4.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d663a8e9a99154b5fb793032533f6328da35e23aac63d5c152279aa8ba356825"
|
||||
checksum = "b585a98a234c46fc563103e9278c9391fde1f4e6850334da895d27edb9580f62"
|
||||
|
||||
[[package]]
|
||||
name = "arrayvec"
|
||||
|
@ -390,9 +390,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "git2"
|
||||
version = "0.13.0"
|
||||
version = "0.13.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b7da16ceafe24cedd9ba02c4463a2b506b6493baf4317c79c5acb553134a3c15"
|
||||
checksum = "2cfb93ca10f2934069c3aaafb753fbe0663f08ee009a01b6d62e062391447b15"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"libc",
|
||||
|
@ -461,9 +461,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.1.8"
|
||||
version = "0.1.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1010591b26bbfe835e9faeabeb11866061cc7dcebffd56ad7d0942d0e61aefd8"
|
||||
checksum = "8a0d737e0f947a1864e93d33fdef4af8445a00d1ed8dc0c8ddb73139ea6abf15"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
@ -613,15 +613,15 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.68"
|
||||
version = "0.2.69"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dea0c0405123bba743ee3f91f49b1c7cfb684eef0da0a50110f758ccf24cdff0"
|
||||
checksum = "99e85c08494b21a9054e7fe1374a732aeadaff3980b6990b94bfd3a70f690005"
|
||||
|
||||
[[package]]
|
||||
name = "libgit2-sys"
|
||||
version = "0.12.0+0.99.0"
|
||||
version = "0.12.3+1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "05dff41ac39e7b653f5f1550886cf00ba52f8e7f57210b633cdeedb3de5b236c"
|
||||
checksum = "7637dc15e7f05a16011723e0448655081fc01a374bcd368e2c9b9c7f5c5ab3ea"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
|
@ -807,9 +807,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "num_cpus"
|
||||
version = "1.12.0"
|
||||
version = "1.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "46203554f085ff89c235cd12f7075f3233af9b11ed7c9e16dfe2560d03313ce6"
|
||||
checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3"
|
||||
dependencies = [
|
||||
"hermit-abi",
|
||||
"libc",
|
||||
|
@ -856,9 +856,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "parking_lot_core"
|
||||
version = "0.7.1"
|
||||
version = "0.7.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0e136c1904604defe99ce5fd71a28d473fa60a12255d511aa78a9ddf11237aeb"
|
||||
checksum = "d58c7c768d4ba344e3e8d72518ac13e259d7c7ade24167003b8488e10b6740a3"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cloudabi",
|
||||
|
@ -1168,9 +1168,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.48"
|
||||
version = "1.0.51"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9371ade75d4c2d6cb154141b9752cf3781ec9c05e0e5cf35060e1e70ee7b9c25"
|
||||
checksum = "da07b57ee2623368351e9a0488bb0b261322a15a6e0ae53e243cbdc0f4208da9"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"ryu",
|
||||
|
@ -1213,9 +1213,9 @@ checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8"
|
|||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
version = "1.2.0"
|
||||
version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c2fb2ec9bcd216a5b0d0ccf31ab17b5ed1d627960edff65bbe95d3ce221cefc"
|
||||
checksum = "05720e22615919e4734f6a99ceae50d00226c3c5aca406e102ebc33298214e0a"
|
||||
|
||||
[[package]]
|
||||
name = "socket2"
|
||||
|
@ -1336,12 +1336,11 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "time"
|
||||
version = "0.1.42"
|
||||
version = "0.1.43"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f"
|
||||
checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"redox_syscall",
|
||||
"winapi 0.3.8",
|
||||
]
|
||||
|
||||
|
@ -1600,9 +1599,9 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
|||
|
||||
[[package]]
|
||||
name = "winapi-util"
|
||||
version = "0.1.3"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4ccfbf554c6ad11084fb7517daca16cfdcaccbdadba4fc336f032a8b12c2ad80"
|
||||
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
|
||||
dependencies = [
|
||||
"winapi 0.3.8",
|
||||
]
|
||||
|
|
33
Cargo.toml
33
Cargo.toml
|
@ -1,37 +1,8 @@
|
|||
[package]
|
||||
name = "fedhub"
|
||||
version = "0.1.0"
|
||||
authors = ["Michael Zhang <iptq@protonmail.com>"]
|
||||
edition = "2018"
|
||||
license = "MIT/Apache-2.0"
|
||||
|
||||
[workspace]
|
||||
members = [
|
||||
"async-git",
|
||||
"async-zlib",
|
||||
"fedhub",
|
||||
"fedhub-shell",
|
||||
"fedhub-hooks",
|
||||
]
|
||||
|
||||
[dependencies]
|
||||
anyhow = { version = "1.0.28", default-features = false, features = ["std"] }
|
||||
async-git = { path = "async-git" }
|
||||
comrak = { version = "0.7.0", default-features = false }
|
||||
futures = { version = "0.3.4", default-features = false }
|
||||
git2 = { version = "0.13.0", default-features = false }
|
||||
hyper = { version = "0.13.5", default-features = false, features = ["runtime"] }
|
||||
lazy_static = { version = "1.4.0", default-features = false }
|
||||
packer = { version = "0.5.3", default-features = false }
|
||||
parking_lot = { version = "0.10.2", default-features = false }
|
||||
redis = { version = "0.15.1", default-features = false }
|
||||
serde = { version = "1.0.105", default-features = false }
|
||||
serde_derive = { version = "1.0.105", default-features = false }
|
||||
serde_json = { version = "1.0.48", default-features = false }
|
||||
structopt = { version = "0.3.13", default-features = false }
|
||||
tera = { version = "1.2.0", default-features = false }
|
||||
tokio = { version = "0.2.18", default-features = false, features = ["full"] }
|
||||
toml = { version = "0.5.6", default-features = false }
|
||||
walkdir = { version = "2.3.1", default-features = false }
|
||||
|
||||
[build-dependencies]
|
||||
rsass = "0.13.0"
|
||||
]
|
|
@ -1,9 +1,11 @@
|
|||
mod commit;
|
||||
mod hash_object;
|
||||
mod object;
|
||||
mod r#ref;
|
||||
mod repo;
|
||||
|
||||
pub use self::commit::Commit;
|
||||
pub use self::hash_object::hash_object;
|
||||
pub use self::object::{Object, Oid};
|
||||
pub use self::r#ref::Ref;
|
||||
pub use self::repo::Repository;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
use std::path::PathBuf;
|
||||
use std::pin::Pin;
|
||||
|
||||
use std::str::FromStr;
|
||||
use std::task::{Context, Poll};
|
||||
|
||||
use anyhow::Error;
|
||||
use async_zlib::ZlibDecoder;
|
||||
|
@ -9,7 +8,7 @@ use tokio::{fs::File, io::AsyncReadExt};
|
|||
use typenum::U19;
|
||||
|
||||
use crate::plumbing::Commit;
|
||||
use crate::util::{self, ZlibIO};
|
||||
use crate::util::{self};
|
||||
|
||||
pub struct Object {
|
||||
repo_path: PathBuf,
|
||||
|
|
16
async-git/src/plumbing/ref.rs
Normal file
16
async-git/src/plumbing/ref.rs
Normal file
|
@ -0,0 +1,16 @@
|
|||
use anyhow::Result;
|
||||
|
||||
use crate::plumbing::Oid;
|
||||
|
||||
pub struct Ref {
|
||||
target: Option<Oid>,
|
||||
}
|
||||
|
||||
impl Ref {
|
||||
pub fn parse(string: impl AsRef<str>) -> Result<Self> {
|
||||
let string = string.as_ref();
|
||||
if string.starts_with("ref") {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,22 +1,47 @@
|
|||
use std::path::Path;
|
||||
use std::env;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use anyhow::Result;
|
||||
|
||||
pub struct Repository {}
|
||||
use crate::plumbing::Ref;
|
||||
use crate::util;
|
||||
|
||||
pub struct Repository {
|
||||
path: PathBuf,
|
||||
}
|
||||
|
||||
impl Repository {
|
||||
pub async fn open(path: impl AsRef<Path>) {}
|
||||
}
|
||||
pub async fn open(path: PathBuf) -> Result<Self> {
|
||||
if !Repository::is_repo(path.clone()).await? {
|
||||
bail!("not a repository");
|
||||
}
|
||||
|
||||
pub async fn is_repo(path: impl AsRef<Path>) -> Result<bool> {
|
||||
Ok(false)
|
||||
}
|
||||
|
||||
/// Find the closest repository that the current repository belongs to.
|
||||
pub async fn find() -> Result<Option<Repository>> {
|
||||
let mut cwd = env::current_dir()?;
|
||||
loop {
|
||||
Ok(Repository { path })
|
||||
}
|
||||
|
||||
pub async fn head(self) -> Result<Ref> {
|
||||
let head_path = self.path.join("HEAD");
|
||||
let head_ref = util::file_to_string(head_path).await?.trim();
|
||||
Ok(Ref::parse(head_ref)?)
|
||||
}
|
||||
|
||||
pub async fn is_repo(path: PathBuf) -> Result<bool> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
/// Find the closest repository that the current repository belongs to.
|
||||
pub async fn find() -> Result<Option<PathBuf>> {
|
||||
let mut cwd = env::current_dir()?;
|
||||
|
||||
loop {
|
||||
if Repository::is_repo(cwd.clone()).await? {
|
||||
return Ok(Some(cwd));
|
||||
}
|
||||
|
||||
cwd = match cwd.parent() {
|
||||
Some(parent) => parent.to_path_buf(),
|
||||
None => return Ok(None),
|
||||
};
|
||||
}
|
||||
}
|
||||
Ok(None)
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
use crate::plumbing::Oid;
|
||||
use anyhow::Result;
|
||||
|
||||
use crate::plumbing::{Oid, Repository};
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
pub struct ShowOptions {
|
||||
|
@ -6,8 +8,14 @@ pub struct ShowOptions {
|
|||
objects: Vec<Oid>,
|
||||
}
|
||||
|
||||
pub async fn show_cmd(options: ShowOptions) {
|
||||
pub async fn show_cmd(options: ShowOptions) -> Result<()> {
|
||||
let mut objects = options.objects;
|
||||
let repo = match Repository::find().await? {
|
||||
Some(path) => Repository::open(path),
|
||||
None => bail!("not in a repository lmao"),
|
||||
};
|
||||
|
||||
for id in objects {}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
use std::io;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use async_zlib::{ZlibDecoder, ZlibEncoder};
|
||||
use tokio::{fs::File, io::AsyncWriteExt};
|
||||
use tokio::{
|
||||
fs::File,
|
||||
io::{AsyncReadExt, AsyncWriteExt},
|
||||
};
|
||||
use typenum::Unsigned;
|
||||
|
||||
/// Marker trait to ensure compression/decompression is already happening transparently.
|
||||
|
@ -37,3 +41,10 @@ pub async fn init_file(path: impl AsRef<Path>, contents: impl AsRef<str>) -> Res
|
|||
file.write_all(contents.as_ref().as_bytes()).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn file_to_string(path: PathBuf) -> Result<String, io::Error> {
|
||||
let mut file = File::open(path).await?;
|
||||
let mut contents = String::new();
|
||||
file.read_to_string(&mut contents).await?;
|
||||
Ok(contents)
|
||||
}
|
||||
|
|
29
fedhub/Cargo.toml
Normal file
29
fedhub/Cargo.toml
Normal file
|
@ -0,0 +1,29 @@
|
|||
[package]
|
||||
name = "fedhub"
|
||||
version = "0.1.0"
|
||||
authors = ["Michael Zhang <iptq@protonmail.com>"]
|
||||
edition = "2018"
|
||||
license = "MIT/Apache-2.0"
|
||||
|
||||
[dependencies]
|
||||
anyhow = { version = "1.0.28", default-features = false, features = ["std"] }
|
||||
async-git = { path = "../async-git" }
|
||||
comrak = { version = "0.7.0", default-features = false }
|
||||
futures = { version = "0.3.4", default-features = false }
|
||||
git2 = { version = "0.13.0", default-features = false }
|
||||
hyper = { version = "0.13.5", default-features = false, features = ["runtime"] }
|
||||
lazy_static = { version = "1.4.0", default-features = false }
|
||||
packer = { version = "0.5.3", default-features = false }
|
||||
parking_lot = { version = "0.10.2", default-features = false }
|
||||
redis = { version = "0.15.1", default-features = false }
|
||||
serde = { version = "1.0.105", default-features = false }
|
||||
serde_derive = { version = "1.0.105", default-features = false }
|
||||
serde_json = { version = "1.0.48", default-features = false }
|
||||
structopt = { version = "0.3.13", default-features = false }
|
||||
tera = { version = "1.2.0", default-features = false }
|
||||
tokio = { version = "0.2.18", default-features = false, features = ["full"] }
|
||||
toml = { version = "0.5.6", default-features = false }
|
||||
walkdir = { version = "2.3.1", default-features = false }
|
||||
|
||||
[build-dependencies]
|
||||
rsass = "0.13.0"
|
Loading…
Reference in a new issue