Skip to content

Commit bb84248

Browse files
committed
cargo fmt
1 parent d79f896 commit bb84248

File tree

5 files changed

+37
-28
lines changed

5 files changed

+37
-28
lines changed

gix-refspec/src/parse.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,11 @@ pub(crate) mod function {
151151
spec.len() >= gix_hash::Kind::shortest().len_in_hex() && spec.iter().all(u8::is_ascii_hexdigit)
152152
}
153153

154-
fn validated(spec: Option<&BStr>, allow_revspecs: bool, is_one_sided: bool) -> Result<(Option<&BStr>, bool), Error> {
154+
fn validated(
155+
spec: Option<&BStr>,
156+
allow_revspecs: bool,
157+
is_one_sided: bool,
158+
) -> Result<(Option<&BStr>, bool), Error> {
155159
match spec {
156160
Some(spec) => {
157161
let glob_count = spec.iter().filter(|b| **b == b'*').take(2).count();

gix-refspec/tests/refspec/match_group.rs

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,9 @@ mod multiple {
186186
}
187187

188188
mod complex_globs {
189-
use gix_refspec::{parse::Operation, MatchGroup};
190-
use gix_hash::ObjectId;
191189
use bstr::BString;
190+
use gix_hash::ObjectId;
191+
use gix_refspec::{parse::Operation, MatchGroup};
192192
use std::borrow::Cow;
193193

194194
#[test]
@@ -197,18 +197,21 @@ mod complex_globs {
197197
// can now be parsed for one-sided refspecs
198198
let spec1 = gix_refspec::parse("refs/*/foo/*".into(), Operation::Fetch);
199199
assert!(spec1.is_ok(), "Should parse complex glob pattern for one-sided refspec");
200-
200+
201201
let spec2 = gix_refspec::parse("refs/*/*/bar".into(), Operation::Fetch);
202-
assert!(spec2.is_ok(), "Should parse complex glob pattern with multiple asterisks");
203-
202+
assert!(
203+
spec2.is_ok(),
204+
"Should parse complex glob pattern with multiple asterisks"
205+
);
206+
204207
let spec3 = gix_refspec::parse("refs/heads/*/release/*".into(), Operation::Fetch);
205208
assert!(spec3.is_ok(), "Should parse complex glob pattern");
206-
209+
207210
// Two-sided refspecs with multiple asterisks should still fail
208211
let spec4 = gix_refspec::parse("refs/*/foo/*:refs/remotes/*".into(), Operation::Fetch);
209212
assert!(spec4.is_err(), "Two-sided refspecs with multiple asterisks should fail");
210213
}
211-
214+
212215
#[test]
213216
fn one_sided_simple_glob_patterns_match() {
214217
// Test that simple glob patterns (one asterisk) work correctly with matching
@@ -219,25 +222,25 @@ mod complex_globs {
219222
create_ref("refs/pull/123", "4444444444444444444444444444444444444444"),
220223
];
221224
let items: Vec<_> = refs.iter().map(|r| r.to_item()).collect();
222-
225+
223226
// Test: refs/heads/* should match all refs under refs/heads/
224227
let spec = gix_refspec::parse("refs/heads/*".into(), Operation::Fetch).unwrap();
225228
let group = MatchGroup::from_fetch_specs([spec]);
226229
let outcome = group.match_lhs(items.iter().copied());
227230
let mappings = outcome.mappings;
228-
231+
229232
assert_eq!(mappings.len(), 2, "Should match two refs under refs/heads/");
230-
233+
231234
// Test: refs/tags/* should match all refs under refs/tags/
232235
let items2: Vec<_> = refs.iter().map(|r| r.to_item()).collect();
233236
let spec2 = gix_refspec::parse("refs/tags/*".into(), Operation::Fetch).unwrap();
234237
let group2 = MatchGroup::from_fetch_specs([spec2]);
235238
let outcome2 = group2.match_lhs(items2.iter().copied());
236239
let mappings2 = outcome2.mappings;
237-
240+
238241
assert_eq!(mappings2.len(), 1, "Should match one ref under refs/tags/");
239242
}
240-
243+
241244
#[test]
242245
fn one_sided_glob_with_suffix_matches() {
243246
// Test that glob patterns with suffix work correctly
@@ -247,16 +250,16 @@ mod complex_globs {
247250
create_ref("refs/heads/main", "3333333333333333333333333333333333333333"),
248251
];
249252
let items: Vec<_> = refs.iter().map(|r| r.to_item()).collect();
250-
253+
251254
// Test: refs/heads/feat* should match refs/heads/feature and refs/heads/feat
252255
let spec = gix_refspec::parse("refs/heads/feat*".into(), Operation::Fetch).unwrap();
253256
let group = MatchGroup::from_fetch_specs([spec]);
254257
let outcome = group.match_lhs(items.iter().copied());
255258
let mappings = outcome.mappings;
256-
259+
257260
assert_eq!(mappings.len(), 2, "Should match two refs starting with feat");
258261
}
259-
262+
260263
// Helper function to create a ref
261264
fn create_ref(name: &str, id_hex: &str) -> Ref {
262265
Ref {
@@ -265,14 +268,14 @@ mod complex_globs {
265268
object: None,
266269
}
267270
}
268-
271+
269272
#[derive(Debug, Clone)]
270273
struct Ref {
271274
name: BString,
272275
target: ObjectId,
273276
object: Option<ObjectId>,
274277
}
275-
278+
276279
impl Ref {
277280
fn to_item(&self) -> gix_refspec::match_group::Item<'_> {
278281
gix_refspec::match_group::Item {

gix-refspec/tests/refspec/parse/fetch.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,18 +180,16 @@ fn complex_glob_patterns_are_allowed_in_one_sided_refspecs() {
180180
// Complex patterns with multiple asterisks should work for one-sided refspecs
181181
assert_parse(
182182
"refs/*/foo/*",
183-
Instruction::Fetch(Fetch::Only {
184-
src: b("refs/*/foo/*"),
185-
}),
183+
Instruction::Fetch(Fetch::Only { src: b("refs/*/foo/*") }),
186184
);
187-
185+
188186
assert_parse(
189187
"+refs/heads/*/release/*",
190188
Instruction::Fetch(Fetch::Only {
191189
src: b("refs/heads/*/release/*"),
192190
}),
193191
);
194-
192+
195193
// Even more complex patterns
196194
assert_parse(
197195
"refs/*/*/branch",

gix-refspec/tests/refspec/parse/invalid.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ fn complex_patterns_with_more_than_one_asterisk() {
3131
for op in [Operation::Fetch, Operation::Push] {
3232
assert!(try_parse("a/*/c/*", op).is_ok());
3333
}
34-
34+
3535
// For two-sided refspecs, complex patterns should still fail
3636
for op in [Operation::Fetch, Operation::Push] {
3737
for spec in ["a/*/c/*:x/*/y/*", "a**:**b", "+:**/"] {
@@ -41,7 +41,7 @@ fn complex_patterns_with_more_than_one_asterisk() {
4141
));
4242
}
4343
}
44-
44+
4545
// Negative specs with multiple patterns still fail
4646
assert!(matches!(
4747
try_parse("^*/*", Operation::Fetch).unwrap_err(),
@@ -61,7 +61,7 @@ fn both_sides_need_pattern_if_one_uses_it() {
6161
);
6262
}
6363
}
64-
64+
6565
// One-sided refspecs with patterns are now allowed
6666
for op in [Operation::Fetch, Operation::Push] {
6767
assert!(try_parse("refs/*/a", op).is_ok());

gix-refspec/tests/refspec/parse/mod.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,14 @@ fn baseline() {
7070
panics
7171
);
7272
}
73-
73+
7474
fn is_one_sided_glob_pattern(spec: &[u8], op: Operation) -> bool {
7575
use bstr::ByteSlice;
76-
matches!(op, Operation::Fetch) && spec.to_str().map(|s| s.contains('*') && !s.contains(':')).unwrap_or(false)
76+
matches!(op, Operation::Fetch)
77+
&& spec
78+
.to_str()
79+
.map(|s| s.contains('*') && !s.contains(':'))
80+
.unwrap_or(false)
7781
}
7882
}
7983

0 commit comments

Comments
 (0)