Skip to content

Commit

Permalink
Upgrade to Winnow 0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Aug 2, 2023
1 parent f7efe39 commit 9ff488f
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 20 deletions.
12 changes: 6 additions & 6 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion gix-actor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ gix-date = { version = "^0.7.1", path = "../gix-date" }
thiserror = "1.0.38"
btoi = "0.4.2"
bstr = { version = "1.3.0", default-features = false, features = ["std", "unicode"]}
winnow = "0.3"
winnow = "0.4"
itoa = "1.0.1"
serde = { version = "1.0.114", optional = true, default-features = false, features = ["derive"]}

Expand Down
10 changes: 5 additions & 5 deletions gix-actor/src/signature/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub(crate) mod function {
.and_then(|(i, v)| {
btoi::<SecondsSinceUnixEpoch>(v)
.map(|v| (i, v))
.map_err(|_| winnow::error::ErrMode::from_error_kind(i, winnow::error::ErrorKind::MapRes))
.map_err(|_| winnow::error::ErrMode::from_error_kind(i, winnow::error::ErrorKind::Verify))
})
})
.context("<timestamp>"),
Expand All @@ -46,7 +46,7 @@ pub(crate) mod function {
.and_then(|(i, v)| {
btoi::<OffsetInSeconds>(v)
.map(|v| (i, v))
.map_err(|_| winnow::error::ErrMode::from_error_kind(i, winnow::error::ErrorKind::MapRes))
.map_err(|_| winnow::error::ErrMode::from_error_kind(i, winnow::error::ErrorKind::Verify))
})
})
.context("HH"),
Expand All @@ -56,7 +56,7 @@ pub(crate) mod function {
.and_then(|(i, v)| {
btoi::<OffsetInSeconds>(v)
.map(|v| (i, v))
.map_err(|_| winnow::error::ErrMode::from_error_kind(i, winnow::error::ErrorKind::MapRes))
.map_err(|_| winnow::error::ErrMode::from_error_kind(i, winnow::error::ErrorKind::Verify))
})
})
.context("MM"),
Expand Down Expand Up @@ -188,7 +188,7 @@ mod tests {
.map_err(to_bstr_err)
.expect_err("parse fails as > is missing")
.to_string(),
"Parse error:\nTakeUntil at: 12345 -1215\nin section '<email>', at: 12345 -1215\nin section '<name> <<email>>', at: hello < 12345 -1215\nin section '<name> <<email>> <timestamp> <+|-><HHMM>', at: hello < 12345 -1215\n"
"Parse error:\nSlice at: 12345 -1215\nin section '<email>', at: 12345 -1215\nin section '<name> <<email>>', at: hello < 12345 -1215\nin section '<name> <<email>> <timestamp> <+|-><HHMM>', at: hello < 12345 -1215\n"
);
}

Expand All @@ -199,7 +199,7 @@ mod tests {
.map_err(to_bstr_err)
.expect_err("parse fails as > is missing")
.to_string(),
"Parse error:\nMapRes at: -1215\nin section '<timestamp>', at: abc -1215\nin section '<name> <<email>> <timestamp> <+|-><HHMM>', at: hello <> abc -1215\n"
"Parse error:\nVerify at: -1215\nin section '<timestamp>', at: abc -1215\nin section '<name> <<email>> <timestamp> <+|-><HHMM>', at: hello <> abc -1215\n"
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion gix-object/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ itoa = "1.0.1"
thiserror = "1.0.34"
hex = "0.4.2"
bstr = { version = "1.3.0", default-features = false, features = ["std", "unicode"] }
winnow = "0.3"
winnow = "0.4"
smallvec = { version = "1.4.0", features = ["write"] }
serde = { version = "1.0.114", optional = true, default-features = false, features = ["derive"]}

Expand Down
2 changes: 1 addition & 1 deletion gix-object/src/tag/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub fn git_tag<'a, E: ParseError<&'a [u8]> + ContextError<&'a [u8]>>(i: &'a [u8]
.context("type <object kind>")
.parse_next(i)?;
let kind = crate::Kind::from_bytes(kind)
.map_err(|_| winnow::error::ErrMode::from_error_kind(i, winnow::error::ErrorKind::MapRes))?;
.map_err(|_| winnow::error::ErrMode::from_error_kind(i, winnow::error::ErrorKind::Verify))?;

let (i, tag_version) = (|i| parse::header_field(i, b"tag", take_while1(|b| b != NL[0])))
.context("tag <version>")
Expand Down
2 changes: 1 addition & 1 deletion gix-object/src/tag/ref_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl<'a> TagRefIter<'a> {
.context("type <object kind>")
.parse_next(i)?;
let kind = Kind::from_bytes(kind)
.map_err(|_| winnow::error::ErrMode::from_error_kind(i, winnow::error::ErrorKind::MapRes))?;
.map_err(|_| winnow::error::ErrMode::from_error_kind(i, winnow::error::ErrorKind::Verify))?;
*state = Name;
(i, Token::TargetKind(kind))
}
Expand Down
4 changes: 2 additions & 2 deletions gix-object/src/tree/ref_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl<'a> Iterator for TreeRefIter<'a> {
#[allow(clippy::unit_arg)]
Some(Err(winnow::error::ErrMode::from_error_kind(
&[] as &[u8],
winnow::error::ErrorKind::MapRes,
winnow::error::ErrorKind::Verify,
)
.into()))
}
Expand Down Expand Up @@ -163,7 +163,7 @@ mod decode {
pub fn entry<'a, E: ParseError<&'a [u8]>>(i: &'a [u8]) -> IResult<&[u8], EntryRef<'_>, E> {
let (i, mode) = terminated(take_while_m_n(5, 6, AsChar::is_dec_digit), SPACE).parse_next(i)?;
let mode = tree::EntryMode::try_from(mode)
.map_err(|invalid| winnow::error::ErrMode::from_error_kind(invalid, winnow::error::ErrorKind::MapRes))?;
.map_err(|invalid| winnow::error::ErrMode::from_error_kind(invalid, winnow::error::ErrorKind::Verify))?;
let (i, filename) = terminated(take_while1(|b| b != NULL[0]), NULL).parse_next(i)?;
let (i, oid) = take(20u8).parse_next(i)?; // TODO: make this compatible with other hash lengths

Expand Down
2 changes: 1 addition & 1 deletion gix-ref/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ gix-lock = { version = "^7.0.0", path = "../gix-lock" }
gix-tempfile = { version = "^7.0.0", default-features = false, path = "../gix-tempfile" }

thiserror = "1.0.34"
winnow = "0.3"
winnow = "0.4"
serde = { version = "1.0.114", optional = true, default-features = false, features = ["derive"]}

# packed refs
Expand Down
2 changes: 1 addition & 1 deletion gix-ref/src/store/file/log/line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ pub mod decode {
if let Some(first) = message.first() {
if !first.is_ascii_whitespace() {
return Err(
winnow::error::ErrMode::from_error_kind(i, winnow::error::ErrorKind::MapRes).map(|err: E| {
winnow::error::ErrMode::from_error_kind(i, winnow::error::ErrorKind::Verify).map(|err: E| {
err.add_context(i, "log message must be separated from signature with whitespace")
}),
);
Expand Down
2 changes: 1 addition & 1 deletion tests/tools/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ gix-worktree = "0.17.0"
gix-fs = { version = "^0.4.1", path = "../../gix-fs" }
gix-tempfile = { version = "^7.0.0", default-features = false, features = ["signals"], path = "../../gix-tempfile" }

winnow = "0.3"
winnow = "0.4"
fastrand = "2.0.0"
bstr = { version = "1.5.0", default-features = false }
crc = "3.0.0"
Expand Down

0 comments on commit 9ff488f

Please sign in to comment.