From 5936f798e9e7fa707fe4587401402ec512e45c16 Mon Sep 17 00:00:00 2001 From: Kurtis Rainbolt-Greene Date: Fri, 5 Jan 2024 12:50:54 -0800 Subject: [PATCH 1/4] For the purposes of negative globs, treat them as positive globs. In Github you can define a "negative glob" aka, "not this path". To still validate this type of glob we simply check the opposite of that path. --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 0aad0a8..065b742 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -196,7 +196,7 @@ fn validate_globs(globs: &serde_json::Value, path: &str, state: &mut ValidationS if let Some(globs) = globs.as_array() { for g in globs { - match glob(g.as_str().unwrap()) { + match glob(g.as_str().replace("!", "").unwrap()) { Ok(res) => { if res.count() == 0 { state.errors.push(ValidationError::NoFilesMatchingGlob { From d70b35915828f316771c9309bda0a923c3b41652 Mon Sep 17 00:00:00 2001 From: Kurtis Rainbolt-Greene Date: Sat, 6 Jan 2024 07:38:03 -0600 Subject: [PATCH 2/4] Maybe g.as_str() returns something that needs to be unwrapped before replace is called? This is my second line of rust code ever written. --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 065b742..fcd7a28 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -196,7 +196,7 @@ fn validate_globs(globs: &serde_json::Value, path: &str, state: &mut ValidationS if let Some(globs) = globs.as_array() { for g in globs { - match glob(g.as_str().replace("!", "").unwrap()) { + match glob(g.as_str().unwrap().replace("!", "")) { Ok(res) => { if res.count() == 0 { state.errors.push(ValidationError::NoFilesMatchingGlob { From 3828ecadbb151b44f8774a221acf4643d9916a67 Mon Sep 17 00:00:00 2001 From: Kurtis Rainbolt-Greene Date: Sat, 6 Jan 2024 07:40:57 -0600 Subject: [PATCH 3/4] Adding a negative glob for testing --- test/003_successful_globs/glob.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/test/003_successful_globs/glob.yml b/test/003_successful_globs/glob.yml index 6608e8b..fd7d49b 100644 --- a/test/003_successful_globs/glob.yml +++ b/test/003_successful_globs/glob.yml @@ -4,6 +4,7 @@ on: push: paths: - 003_successful_globs/* + - !003_successful_globs/* defaults: run: From 91ad200100038d1fa271f920f4ec884bdf5337e7 Mon Sep 17 00:00:00 2001 From: Kurtis Rainbolt-Greene Date: Mon, 8 Jan 2024 10:07:57 -0800 Subject: [PATCH 4/4] I have no idea what I'm doing --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index fcd7a28..4f8ab08 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -196,7 +196,7 @@ fn validate_globs(globs: &serde_json::Value, path: &str, state: &mut ValidationS if let Some(globs) = globs.as_array() { for g in globs { - match glob(g.as_str().unwrap().replace("!", "")) { + match glob(&g.as_str().unwrap().replace("!", "")) { Ok(res) => { if res.count() == 0 { state.errors.push(ValidationError::NoFilesMatchingGlob {