Skip to content

Commit 0ac9c5a

Browse files
committed
reorganize crates to make 'gitoxide' the CLI, and 'gitoxide-core' the library
The latter at least doesn't have to pull in CLI stuff, and allows people to more easily reuse all functionality of gitoxide.
1 parent 1331336 commit 0ac9c5a

File tree

6 files changed

+51
-27
lines changed

6 files changed

+51
-27
lines changed

Diff for: Cargo.lock

+9-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ test = false
1414
doctest = false
1515

1616
[dependencies]
17-
git-repository = { version = "0.1.0", path = "git-repository" }
18-
git-odb = { version = "0.1.0", path = "git-odb", default-features = false, features = ["fast-sha1"] }
17+
gitoxide-core = { version = "0.1.0", path = "gitoxide-core" }
1918
anyhow = "1.0.31"
2019
structopt = "0.3.14"
2120

@@ -28,6 +27,7 @@ incremental = false
2827

2928
[workspace]
3029
members = [
30+
"gitoxide-core",
3131
"git-object",
3232
"git-odb",
3333
"git-repository",

Diff for: README.md

+9-15
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,12 @@
11
[![Rust](https://github.com/Byron/git-oxide/workflows/Rust/badge.svg)](https://github.com/Byron/git-oxide/actions)
22

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

6-
The CLI uses various libraries to implement
7+
The CLI uses various crates, please see _'Development Status'_ for details.
78

8-
* [ ] a git *repository* and *references* (see `git-core`)
9-
* [ ] encoding and decoding git objects (see `git-object`)
10-
* [ ] a git object database (see `git-odb` and
11-
[examples](https://github.com/Byron/git-oxide/tree/master/lib/git-odb/examples))
12-
* [ ] a transport layer for push and pull (see `git-transport`)
13-
14-
**This project is early in development and currently strictly for fun**
15-
16-
**Currently I am implementing whatever is needed to set a new record for solving
17-
[this
18-
problem](https://github.com/gitpython-developers/GitPython/issues/765#issuecomment-396072153)**
19-
20-
## Tasks
9+
## Development Status
2110

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

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

Diff for: gitoxide-core/Cargo.toml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[package]
2+
name = "gitoxide-core"
3+
description = "The library implementating all capabilities of the gitoxide CLI"
4+
version = "0.1.0"
5+
authors = ["Sebastian Thiel <[email protected]>"]
6+
publish = false
7+
license = "MIT"
8+
edition = "2018"
9+
10+
[dependencies]
11+
git-repository = { version = "0.1.0", path = "../git-repository" }
12+
git-odb = { version = "0.1.0", path = "../git-odb", default-features = false, features = ["fast-sha1"] }
13+
anyhow = "1.0.31"

Diff for: gitoxide-core/src/lib.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
use anyhow::{Context, Result};
2+
use std::{io, path::Path};
3+
4+
pub fn init() -> Result<()> {
5+
git_repository::init::repository().with_context(|| "Repository initialization failed")
6+
}
7+
8+
pub fn verify_pack_or_pack_index(path: impl AsRef<Path>, mut out: impl io::Write) -> Result<()> {
9+
let pack = git_odb::pack::File::at(path).with_context(|| "Could not open pack file")?;
10+
pack.verify_checksum().with_context(|| "Failed")?;
11+
writeln!(out, "OK")?;
12+
Ok(())
13+
}

Diff for: src/main.rs

+5-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#![forbid(unsafe_code)]
22

3-
use anyhow::{Context, Result};
3+
use anyhow::Result;
4+
use gitoxide_core as core;
5+
use std::io::stdout;
46
use structopt::StructOpt;
57

68
mod options {
@@ -48,16 +50,10 @@ mod options {
4850
fn main() -> Result<()> {
4951
let args = options::Args::from_args();
5052
match args.cmd {
51-
options::Subcommands::Init => {
52-
git_repository::init::repository().with_context(|| "Repository initialization failed")
53-
}
53+
options::Subcommands::Init => core::init(),
5454
options::Subcommands::Plumbing(cmd) => match cmd {
5555
options::Plumbing::VerifyPack { path } => {
56-
let pack =
57-
git_odb::pack::File::at(path).with_context(|| "Could not open pack file")?;
58-
pack.verify_checksum().with_context(|| "Failed")?;
59-
println!("OK");
60-
Ok(())
56+
core::verify_pack_or_pack_index(path, stdout())
6157
}
6258
},
6359
}?;

0 commit comments

Comments
 (0)