-
Notifications
You must be signed in to change notification settings - Fork 3
feat: support go 1.24 ignore directives #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ pub(crate) enum Directive<'a> { | |
| Exclude(Vec<ModuleDependency>), | ||
| Replace(Vec<ModuleReplacement>), | ||
| Retract(Vec<ModuleRetract>), | ||
| Ignore(Vec<String>), | ||
| } | ||
|
|
||
| pub(crate) fn gomod<'a>(input: &mut &'a str) -> Result<Vec<Directive<'a>>> { | ||
|
|
@@ -44,6 +45,7 @@ fn directive<'a>(input: &mut &'a str) -> Result<Directive<'a>> { | |
| "exclude" => exclude, | ||
| "replace" => replace, | ||
| "retract" => retract, | ||
| "ignore" => ignore, | ||
| _ => fail, | ||
| ) | ||
| .parse_next(input) | ||
|
|
@@ -294,3 +296,38 @@ fn retract_multi(input: &mut &str) -> Result<Vec<ModuleRetract>> { | |
|
|
||
| Ok(res.into_iter().flatten().collect::<Vec<ModuleRetract>>()) | ||
| } | ||
|
|
||
| fn ignore<'a>(input: &mut &'a str) -> Result<Directive<'a>> { | ||
| let res = preceded( | ||
| ("ignore", space1), | ||
| dispatch! {peek(any); | ||
| '(' => ignore_multi, | ||
| _ => ignore_single, | ||
| }, | ||
| ) | ||
| .parse_next(input)?; | ||
| let _ = take_while(0.., CRLF).parse_next(input)?; | ||
|
|
||
| Ok(Directive::Ignore(res)) | ||
| } | ||
|
|
||
| fn ignore_single(input: &mut &str) -> Result<Vec<String>> { | ||
| // terminate, if `)` is found | ||
| peek(not(')')).parse_next(input)?; | ||
|
|
||
| let path = take_till(1.., WHITESPACES).parse_next(input)?; | ||
|
|
||
| // remove any comments added to the same line | ||
| let _ = opt(comment).parse_next(input)?; | ||
|
|
||
| Ok(vec![path.to_string()]) | ||
| } | ||
|
|
||
| fn ignore_multi(input: &mut &str) -> Result<Vec<String>> { | ||
| let _ = ("(", multispace1).parse_next(input)?; | ||
| let res: Vec<Vec<String>> = | ||
| repeat(1.., terminated(ignore_single, multispace0)).parse_next(input)?; | ||
| let _ = (")", multispace0).parse_next(input)?; | ||
|
Comment on lines
+326
to
+330
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Finding types: Want Baz to fix this for you? Activate Fixer Other fix methodsPrompt for AI Agents |
||
|
|
||
| Ok(res.into_iter().flatten().collect::<Vec<String>>()) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| module github.com/example/ignore | ||
|
|
||
| go 1.24 | ||
|
|
||
| ignore ./build | ||
|
|
||
| ignore ( | ||
| ./testdata | ||
| ./vendor/temp | ||
| ./node_modules | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding public
ignore: Vec<String>toGoModmakesGoMod { ... }construction non-exhaustive, so downstream crates will fail to compile unless they set it too — should we treat this as a breaking change or hide direct construction with a builder/#[non_exhaustive]+ accessors?Finding type:
Breaking Changes| Severity: 🟠 MediumWant Baz to fix this for you? Activate Fixer
Other fix methods
Prompt for AI Agents