Skip to content

Commit

Permalink
parse initial carets (#427)
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed May 29, 2022
1 parent 6c5801a commit 67dc72a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
14 changes: 12 additions & 2 deletions git-revision/src/spec.rs
Expand Up @@ -51,9 +51,19 @@ pub mod parse {

pub(crate) mod function {
use crate::spec::parse::{Delegate, Error};
use bstr::BStr;
use bstr::{BStr, ByteSlice};

fn next(i: &BStr) -> (u8, &BStr) {
let b = i[0];
(b, i[1..].as_bstr()).into()
}

pub fn parse(mut input: &BStr, delegate: &mut impl Delegate) -> Result<(), Error> {
if let Some(b'^') = input.get(0) {
input = next(input).1;
delegate.kind(crate::spec::Kind::Range);
}

pub fn parse(input: &BStr, delegate: &mut impl Delegate) -> Result<(), Error> {
if input == "@" || input == "HEAD" {
return delegate.resolve_ref("HEAD".into()).ok_or(Error::Delegate);
}
Expand Down
1 change: 0 additions & 1 deletion git-revision/tests/spec/mod.rs
Expand Up @@ -65,7 +65,6 @@ mod parse {
}

#[test]
#[ignore]
fn leading_caret_is_range_kind() {
let rec = parse("^HEAD");
assert_eq!(rec.kind.unwrap(), spec::Kind::Range);
Expand Down

0 comments on commit 67dc72a

Please sign in to comment.