Skip to content

Commit

Permalink
reorganize crates to make 'gitoxide' the CLI, and 'gitoxide-core' the…
Browse files Browse the repository at this point in the history
… library

The latter at least doesn't have to pull in CLI stuff, and allows people
to more easily reuse all functionality of gitoxide.
  • Loading branch information
Byron committed Jun 25, 2020
1 parent 1331336 commit 0ac9c5a
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 27 deletions.
10 changes: 9 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ test = false
doctest = false

[dependencies]
git-repository = { version = "0.1.0", path = "git-repository" }
git-odb = { version = "0.1.0", path = "git-odb", default-features = false, features = ["fast-sha1"] }
gitoxide-core = { version = "0.1.0", path = "gitoxide-core" }
anyhow = "1.0.31"
structopt = "0.3.14"

Expand All @@ -28,6 +27,7 @@ incremental = false

[workspace]
members = [
"gitoxide-core",
"git-object",
"git-odb",
"git-repository",
Expand Down
24 changes: 9 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
[![Rust](https://github.com/Byron/git-oxide/workflows/Rust/badge.svg)](https://github.com/Byron/git-oxide/actions)

**gio** is a command-line interface (*CLI*) to access git repositories. It's written to optimize the
user-experience, and perform as good or better than the native implementation.
user-experience, and perform as good or better than the native implementation, and make git tooling more
hackable.

The CLI uses various libraries to implement
The CLI uses various crates, please see _'Development Status'_ for details.

* [ ] a git *repository* and *references* (see `git-core`)
* [ ] encoding and decoding git objects (see `git-object`)
* [ ] a git object database (see `git-odb` and
[examples](https://github.com/Byron/git-oxide/tree/master/lib/git-odb/examples))
* [ ] a transport layer for push and pull (see `git-transport`)

**This project is early in development and currently strictly for fun**

**Currently I am implementing whatever is needed to set a new record for solving
[this
problem](https://github.com/gitpython-developers/GitPython/issues/765#issuecomment-396072153)**

## Tasks
## Development Status

* **git-repository**
* [x] initialize
Expand Down Expand Up @@ -212,3 +201,8 @@ Thus one has to post-process the file by reducing its size by one using `truncat
* **deflate2** _(MIT Licensed)_
* We use various abstractions to implement decompression and compression directly on top of the rather low-level `miniz_oxide` crate

## Fun facts

* Originally I was really fascinated by [this problem](https://github.com/gitpython-developers/GitPython/issues/765#issuecomment-396072153)
and believe that with `gitoxide` it will be possible to provide the fastest implementation for that problem.

13 changes: 13 additions & 0 deletions gitoxide-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "gitoxide-core"
description = "The library implementating all capabilities of the gitoxide CLI"
version = "0.1.0"
authors = ["Sebastian Thiel <sebastian.thiel@icloud.com>"]
publish = false
license = "MIT"
edition = "2018"

[dependencies]
git-repository = { version = "0.1.0", path = "../git-repository" }
git-odb = { version = "0.1.0", path = "../git-odb", default-features = false, features = ["fast-sha1"] }
anyhow = "1.0.31"
13 changes: 13 additions & 0 deletions gitoxide-core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use anyhow::{Context, Result};
use std::{io, path::Path};

pub fn init() -> Result<()> {
git_repository::init::repository().with_context(|| "Repository initialization failed")
}

pub fn verify_pack_or_pack_index(path: impl AsRef<Path>, mut out: impl io::Write) -> Result<()> {
let pack = git_odb::pack::File::at(path).with_context(|| "Could not open pack file")?;
pack.verify_checksum().with_context(|| "Failed")?;
writeln!(out, "OK")?;
Ok(())
}
14 changes: 5 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#![forbid(unsafe_code)]

use anyhow::{Context, Result};
use anyhow::Result;
use gitoxide_core as core;
use std::io::stdout;
use structopt::StructOpt;

mod options {
Expand Down Expand Up @@ -48,16 +50,10 @@ mod options {
fn main() -> Result<()> {
let args = options::Args::from_args();
match args.cmd {
options::Subcommands::Init => {
git_repository::init::repository().with_context(|| "Repository initialization failed")
}
options::Subcommands::Init => core::init(),
options::Subcommands::Plumbing(cmd) => match cmd {
options::Plumbing::VerifyPack { path } => {
let pack =
git_odb::pack::File::at(path).with_context(|| "Could not open pack file")?;
pack.verify_checksum().with_context(|| "Failed")?;
println!("OK");
Ok(())
core::verify_pack_or_pack_index(path, stdout())
}
},
}?;
Expand Down

0 comments on commit 0ac9c5a

Please sign in to comment.