Skip to content

Commit

Permalink
Merge pull request #246 from sourcefrog/ci-typos
Browse files Browse the repository at this point in the history
Add typos workflow
  • Loading branch information
sourcefrog authored Jan 15, 2024
2 parents 8cac94f + 07e026d commit d4d9aeb
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/typos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Typos
on: [pull_request]

jobs:
run:
name: Spell check with Typos
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Check spelling
uses: crate-ci/typos@master
2 changes: 1 addition & 1 deletion src/blockdir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ pub fn block_relpath(hash: &BlockHash) -> String {
impl BlockDir {
pub fn open(transport: Arc<dyn Transport>) -> BlockDir {
/// Cache this many blocks in memory.
// TODO: Change to a cache that tracks the size of strored blocks?
// TODO: Change to a cache that tracks the size of stored blocks?
// As a safe conservative value, 100 blocks of 20MB each would be 2GB.
const BLOCK_CACHE_SIZE: usize = 100;

Expand Down
19 changes: 11 additions & 8 deletions src/excludes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,11 @@ mod tests {

#[test]
fn simple_globs() {
let vec = vec!["fo*", "foo", "bar*"];
let vec = vec!["foo*", "quo", "bar*"];
let exclude = Exclude::from_strings(vec).unwrap();

// Matches in the root
assert!(exclude.matches("/quo"));
assert!(exclude.matches("/foo"));
assert!(exclude.matches("/foobar"));
assert!(exclude.matches("/barBaz"));
Expand All @@ -151,17 +152,19 @@ mod tests {

#[test]
fn path_parse() {
let exclude = Exclude::from_strings(["fo*/bar/baz*"]).unwrap();
assert!(exclude.matches("/foo/bar/baz.rs"))
let exclude = Exclude::from_strings(["foo*/bar/baz*"]).unwrap();
assert!(exclude.matches("/foo1/bar/baz.rs"))
}

#[test]
fn extended_pattern_parse() {
// Note that these are globs, not regexps, so "fo?" means "fo" followed by one character.
let exclude = Exclude::from_strings(["fo?", "ba[abc]", "[!a-z]"]).unwrap();
assert!(exclude.matches("/foo"));
assert!(!exclude.matches("/fo"));
assert!(exclude.matches("/baa"));
// Note that these are globs, not regexps, so "foo?" means "foo" followed by one character.
let exclude = Exclude::from_strings(["foo?", "bar[abc]", "[!a-z]"]).unwrap();
assert!(exclude.matches("/foox"));
assert!(!exclude.matches("/foo"));
assert!(!exclude.matches("/bar"));
assert!(exclude.matches("/bara"));
assert!(exclude.matches("/barb"));
assert!(exclude.matches("/1"));
assert!(!exclude.matches("/a"));
}
Expand Down
2 changes: 1 addition & 1 deletion tests/api/live_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ fn exclude_entries_directory() {
tf.create_file("baz/bas");
tf.create_file("baz/test");

let exclude = Exclude::from_strings(["/**/fooo*", "/**/ba[pqr]", "/**/*bas"]).unwrap();
let exclude = Exclude::from_strings(["/**/fooo*", "/**/??[rs]", "/**/*bas"]).unwrap();

let lt = LiveTree::open(tf.path()).unwrap();
let names = entry_iter_to_apath_strings(
Expand Down

0 comments on commit d4d9aeb

Please sign in to comment.