Skip to content

Commit 67dc72a

Browse files
committed
parse initial carets (#427)
1 parent 6c5801a commit 67dc72a

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

git-revision/src/spec.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,19 @@ pub mod parse {
5151

5252
pub(crate) mod function {
5353
use crate::spec::parse::{Delegate, Error};
54-
use bstr::BStr;
54+
use bstr::{BStr, ByteSlice};
55+
56+
fn next(i: &BStr) -> (u8, &BStr) {
57+
let b = i[0];
58+
(b, i[1..].as_bstr()).into()
59+
}
60+
61+
pub fn parse(mut input: &BStr, delegate: &mut impl Delegate) -> Result<(), Error> {
62+
if let Some(b'^') = input.get(0) {
63+
input = next(input).1;
64+
delegate.kind(crate::spec::Kind::Range);
65+
}
5566

56-
pub fn parse(input: &BStr, delegate: &mut impl Delegate) -> Result<(), Error> {
5767
if input == "@" || input == "HEAD" {
5868
return delegate.resolve_ref("HEAD".into()).ok_or(Error::Delegate);
5969
}

git-revision/tests/spec/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ mod parse {
6565
}
6666

6767
#[test]
68-
#[ignore]
6968
fn leading_caret_is_range_kind() {
7069
let rec = parse("^HEAD");
7170
assert_eq!(rec.kind.unwrap(), spec::Kind::Range);

0 commit comments

Comments
 (0)