Skip to content

Commit

Permalink
failing tests for index rev-parsing (#427)
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Aug 1, 2022
1 parent c2e84a4 commit 502d8c9
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 3 deletions.
10 changes: 9 additions & 1 deletion git-repository/src/revision/spec/parse/delegate.rs
Expand Up @@ -525,7 +525,15 @@ impl<'repo> delegate::Navigate for Delegate<'repo> {

fn index_lookup(&mut self, _path: &BStr, _stage: u8) -> Option<()> {
self.unset_disambiguate_call();
todo!()
match self.repo.index() {
Ok(_index) => {
todo!("index lookup")
}
Err(err) => {
self.err.push(err.into());
None
}
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions git-repository/src/revision/spec/parse/types.rs
Expand Up @@ -61,6 +61,8 @@ pub struct Options {
#[derive(Debug, thiserror::Error)]
#[allow(missing_docs)]
pub enum Error {
#[error(transparent)]
Index(#[from] crate::worktree::open_index::Error),
#[error(transparent)]
RevWalkIterInit(#[from] crate::reference::iter::init::Error),
#[error(transparent)]
Expand Down
Git LFS file not shown
1 change: 1 addition & 0 deletions git-repository/tests/fixtures/make_rev_spec_parse_repos.sh
Expand Up @@ -343,4 +343,5 @@ git init complex_graph
baseline ":/!-mes.age" # negated above
baseline ":/not there" # definitely not in graph
baseline "@^{/!-B}" # negation from branch
baseline ":file" # index lookup, default stage 0
)
26 changes: 26 additions & 0 deletions git-repository/tests/revision/spec/from_bytes/mod.rs
Expand Up @@ -7,6 +7,32 @@ pub use util::*;

mod ambiguous;
mod regex;
mod index {
use crate::revision::spec::from_bytes::{parse_spec, repo};
use git_repository::prelude::ObjectIdExt;
use git_repository::revision::Spec;
use git_testtools::hex_to_id;

#[test]
#[ignore]
fn at_default_stage() {
let repo = repo("complex_graph").unwrap();
assert_eq!(
parse_spec(":file", &repo).unwrap(),
Spec::from_id(hex_to_id("fe27474251f7f8368742f01fbd3bd5666b630a82").attach(&repo))
);

assert_eq!(
parse_spec(":1:file", &repo).unwrap_err().to_string(),
"give hint as to where to find the file in the index and if it exists on disk",
);

assert_eq!(
parse_spec(":foo", &repo).unwrap_err().to_string(),
"does not exist (but use same error message as above, as it's parametric)",
);
}
}

#[test]
fn names_are_made_available_via_references() {
Expand Down

0 comments on commit 502d8c9

Please sign in to comment.