Skip to content

Commit

Permalink
The realization that FileBuffer really shouldn't be used anymore (#293)
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Jan 9, 2022
1 parent aa60fdf commit b481f13
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 4 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions git-index/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ doctest = false
git-hash = { version ="^0.8.0", path = "../git-hash" }

quick-error = "2.0.0"
filebuffer = "0.4.0"

[dev-dependencies]
git-testtools = { path = "../tests/tools"}
3 changes: 2 additions & 1 deletion git-index/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ Most of the test indices are snatched directly from the unit test suite of `git`
./t1700-split-index.sh -r 2 --debug
```

Then one finds all test state and the index in particular in `trash directory/t1700-split-index/.git/index`.
Then one finds all test state and the index in particular in `trash directory/t1700-split-index/.git/index` and can possibly copy it over and use as fixture.
The preferred way is to find a test of interest, and use its setup code within one of our own fixture scripts that are executed once to generate the file of interest.
21 changes: 20 additions & 1 deletion git-index/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,29 @@ pub mod file {
pub mod init {
#![allow(unused)]
use crate::File;
use filebuffer::FileBuffer;
use std::path::Path;

mod error {
use quick_error::quick_error;

quick_error! {
#[derive(Debug)]
pub enum Error {
Io(err: std::io::Error) {
display("An IO error occurred while reading the index")
source(err)
from()
}
}
}
}
pub use error::Error;

impl File {
pub fn at(path: impl AsRef<Path>, object_hash: git_hash::Kind) -> std::io::Result<Self> {
pub fn at(path: impl AsRef<Path>, object_hash: git_hash::Kind) -> Result<Self, Error> {
let data = FileBuffer::open(path)?;

todo!("read file")
}
}
Expand Down
7 changes: 5 additions & 2 deletions git-index/tests/file/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
mod init {
fn file(name: &str) -> git_index::File {
git_index::File::at(crate::index_fixture_path(name), git_hash::Kind::Sha1).unwrap()
}

#[test]
#[ignore]
fn v2() {
let _file = git_index::File::at(crate::index_fixture_path("v2"), git_hash::Kind::Sha1).unwrap();
fn read_v2() {
let _file = file("v2");
}
}

0 comments on commit b481f13

Please sign in to comment.