Skip to content

Commit b481f13

Browse files
committed
The realization that FileBuffer really shouldn't be used anymore (#293)
1 parent aa60fdf commit b481f13

File tree

5 files changed

+29
-4
lines changed

5 files changed

+29
-4
lines changed

Cargo.lock

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

git-index/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ doctest = false
1616
git-hash = { version ="^0.8.0", path = "../git-hash" }
1717

1818
quick-error = "2.0.0"
19+
filebuffer = "0.4.0"
1920

2021
[dev-dependencies]
2122
git-testtools = { path = "../tests/tools"}

git-index/README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ Most of the test indices are snatched directly from the unit test suite of `git`
77
./t1700-split-index.sh -r 2 --debug
88
```
99

10-
Then one finds all test state and the index in particular in `trash directory/t1700-split-index/.git/index`.
10+
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.
11+
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.

git-index/src/lib.rs

+20-1
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,29 @@ pub mod file {
88
pub mod init {
99
#![allow(unused)]
1010
use crate::File;
11+
use filebuffer::FileBuffer;
1112
use std::path::Path;
1213

14+
mod error {
15+
use quick_error::quick_error;
16+
17+
quick_error! {
18+
#[derive(Debug)]
19+
pub enum Error {
20+
Io(err: std::io::Error) {
21+
display("An IO error occurred while reading the index")
22+
source(err)
23+
from()
24+
}
25+
}
26+
}
27+
}
28+
pub use error::Error;
29+
1330
impl File {
14-
pub fn at(path: impl AsRef<Path>, object_hash: git_hash::Kind) -> std::io::Result<Self> {
31+
pub fn at(path: impl AsRef<Path>, object_hash: git_hash::Kind) -> Result<Self, Error> {
32+
let data = FileBuffer::open(path)?;
33+
1534
todo!("read file")
1635
}
1736
}

git-index/tests/file/mod.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
mod init {
2+
fn file(name: &str) -> git_index::File {
3+
git_index::File::at(crate::index_fixture_path(name), git_hash::Kind::Sha1).unwrap()
4+
}
25

36
#[test]
47
#[ignore]
5-
fn v2() {
6-
let _file = git_index::File::at(crate::index_fixture_path("v2"), git_hash::Kind::Sha1).unwrap();
8+
fn read_v2() {
9+
let _file = file("v2");
710
}
811
}

0 commit comments

Comments
 (0)