diff --git a/README.md b/README.md index c201368..bf99eb0 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,33 @@ fedhub Federated git forge. +The software is currently under active development. Expect massive breaking changes. + +Setup +----- + +You will need a copy of the Rust compiler to build this software. The project layout is fairly standard and running `cargo build --all --release` should produce the binaries that you need. + +fedhub has multiple components. The absolute minimum you need to get started is to create a config file. By default, fedhub looks for `config.toml` in your current working directory but you can use `-c` to specify one when running. The config file uses [TOML][1] notation and looks a bit like: + +``` +addr = "127.0.0.1:3000" +repo_root = "./repos" +redis_url = "redis://127.0.0.1" +``` + +For now, you'll need Redis to run this software. I'll look into making a more portable version that uses an in-memory key-value store. + +Project Status +-------------- + +Currently, I'm working on website features as well as liberating myself from libgit2 in parallel. libgit2 bindings contain massive amounts of pointer sharing that this application really doesn't need, since all the information I need lives on disk or in cache (in Redis). + Contact ------- Author: Michael Zhang License: MIT/Apache-2.0 Dual License + +[1]: https://github.com/toml-lang/toml diff --git a/async-git/src/plumbing/ref.rs b/async-git/src/plumbing/ref.rs index b038749..907fbfe 100644 --- a/async-git/src/plumbing/ref.rs +++ b/async-git/src/plumbing/ref.rs @@ -12,5 +12,7 @@ impl Ref { if string.starts_with("ref") { } + + unimplemented!() } } diff --git a/async-git/src/plumbing/repo.rs b/async-git/src/plumbing/repo.rs index 9605a8e..6f8a7d6 100644 --- a/async-git/src/plumbing/repo.rs +++ b/async-git/src/plumbing/repo.rs @@ -21,8 +21,8 @@ impl Repository { pub async fn head(self) -> Result { let head_path = self.path.join("HEAD"); - let head_ref = util::file_to_string(head_path).await?.trim(); - Ok(Ref::parse(head_ref)?) + let head_ref = util::file_to_string(head_path).await?; + Ok(Ref::parse(head_ref.trim())?) } pub async fn is_repo(path: PathBuf) -> Result { diff --git a/docs/redis-keys.md b/docs/redis-keys.md new file mode 100644 index 0000000..ef14a15 --- /dev/null +++ b/docs/redis-keys.md @@ -0,0 +1,6 @@ +redis keys +========== + +List of redis keys and their uses: + +- `repos`: set of repo names. This is computed by recursively walking the `repo_root` directory provided in the config. diff --git a/docs/todos.md b/docs/todos.md index a9c45df..00d164e 100644 --- a/docs/todos.md +++ b/docs/todos.md @@ -1,8 +1,24 @@ stuff i can do right now - async-git -- + + plumbing + * [ ] commit + * [ ] object + * [ ] ref + * [ ] repo + + porcelain + * [x] init + * [ ] show + * [ ] log + * [ ] commit + * [ ] merge +- website features +- caching more lookups future +- abstracting the router? +- dev server for faster reloads + + probably also want scss - ci + + oh boy... diff --git a/fedhub-hooks/README.md b/fedhub-hooks/README.md new file mode 100644 index 0000000..e69de29 diff --git a/fedhub/src/lib.rs b/fedhub/src/lib.rs index 9bdd735..dbaee90 100644 --- a/fedhub/src/lib.rs +++ b/fedhub/src/lib.rs @@ -23,11 +23,11 @@ use walkdir::WalkDir; pub use crate::config::Config; #[derive(Packer)] -#[packer(source = "static", prefixed = false)] +#[packer(source = "fedhub/static", prefixed = false)] pub struct Statics; #[derive(Packer)] -#[packer(source = "templates", prefixed = false)] +#[packer(source = "fedhub/templates", prefixed = false)] pub struct Templates; macro_rules! template { diff --git a/fedhub/src/main.rs b/fedhub/src/main.rs index 8278aba..28b2796 100644 --- a/fedhub/src/main.rs +++ b/fedhub/src/main.rs @@ -1,3 +1,4 @@ +use std::path::PathBuf; use std::convert::Infallible; use std::fs::File; use std::io::Read; @@ -9,10 +10,21 @@ use hyper::{ service::{make_service_fn, service_fn}, Body, Response, Server, }; +use structopt::StructOpt; + +#[derive(StructOpt)] +struct Opt { + /// The path to the configuration file. + #[structopt(name = "config-file", long = "config-file", short = "c")] + config_file: Option, +} #[tokio::main] async fn main() -> Result<()> { - let mut config_file = File::open("config.toml")?; + let opt = Opt::from_args(); + let config_path = opt.config_file.unwrap_or_else(|| "config.toml".into()); + + let mut config_file = File::open(config_path)?; let mut config_str = String::new(); config_file.read_to_string(&mut config_str)?;