feat: support variables in include/exclude glob patterns#161
feat: support variables in include/exclude glob patterns#161alirezanet merged 5 commits intomasterfrom
Conversation
alirezanet
left a comment
There was a problem hiding this comment.
Build is failing right now, and make sure you have enough unit tests and some integration tests to fully make sure this feature working as expected.
| { | ||
| foreach (var pattern in patterns) | ||
| { | ||
| if (pattern.Contains("${args}") && optionArguments is { Length: > 0 }) |
There was a problem hiding this comment.
does this check mean we only support ${args} variable? if not, we should support all possible variables as before
There was a problem hiding this comment.
Currently only ${args} is supported in include/exclude glob patterns. Other variables like ${staged}, ${all-files}, ${last-commit}, and ${git-files} expand to file path lists, not string fragments — embedding file paths as glob patterns doesn't make semantic sense. ${args} is the only variable that provides literal string values (e.g., a directory name) suitable for substitution into a glob pattern like ${args}/**/*.cs.
Fixed in 6efed18. The CI failure was because the integration tests were checking Also expanded integration test coverage to 4 tests:
|
alirezanet
left a comment
There was a problem hiding this comment.
add a couple of tests to make sure the old behavior is still working,
1- old behavior with a variable
2- old behavior without any variable
3- also new behavior without any variable and just with some glob patterns
Added 4 regression tests in fb03f67:
|
Updated [husky](https://github.com/alirezanet/husky.net) from 0.8.0 to 0.9.1. <details> <summary>Release notes</summary> _Sourced from [husky's releases](https://github.com/alirezanet/husky.net/releases)._ ## 0.9.1 ## What's Changed * Fix install command race condition on first run with parallel MSBuild nodes by @MattKotsenas in alirezanet/Husky.Net#168 **Full Changelog**: alirezanet/Husky.Net@v0.9.0...v0.9.1 ## 0.9.0 ## What's Changed * remove net6.0/net7.0 since out of support by @WeihanLi in alirezanet/Husky.Net#135 * fix: update regex pattern to allow breaking commits by @joaoopereira in alirezanet/Husky.Net#153 * Fix parallel install mutex bug and support incremental build by @MattKotsenas in alirezanet/Husky.Net#159 * fix: handle file paths with spaces in git commands in alirezanet/Husky.Net#156 * feat: add `staged` property to custom variables for re-staging support in alirezanet/Husky.Net#163 * feat: support variables in include/exclude glob patterns in alirezanet/Husky.Net#161 * fix: use AfterTargets="Restore" to support NuGet credential helpers for private feeds in alirezanet/Husky.Net#162 ## New Contributors * @joaoopereira made their first contribution in alirezanet/Husky.Net#153 * @MattKotsenas made their first contribution in alirezanet/Husky.Net#159 **Full Changelog**: alirezanet/Husky.Net@v0.8.0...v0.9.0 Commits viewable in [compare view](alirezanet/Husky.Net@v0.8.0...v0.9.1). </details> [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Variables like
${args}were only resolved in taskargs, not ininclude/excludeglob patterns. This prevented users from scoping file matching to a runtime-provided directory — a common need in multi-solution repos wheredotnet formatshould only run against solutions containing staged files.Example use case:
{ "tasks": [ { "name": "dotnet-format-staged-files", "command": "dotnet", "args": ["format", "${args}", "--include", "${staged}"], "include": ["${args}/**/*.cs"] } ] }Run with:
dotnet husky run --args src/MySolutionChanges
ArgumentParser.GetPatternMatcher— accepts optionaloptionArguments; expands${args}in each include/exclude pattern, yielding one pattern per argument value (supports multiple--args)ArgumentParser.ParseAsync— forwardsoptionArgumentstoGetPatternMatcherExecutableTaskFactory.CheckIfWeShouldSkipTheTask— accepts and forwardsoptionArgumentstoGetPatternMatcherso skip-checks honour variable-based patternsIssue113Tests.cs— 8 integration tests total:${args}variable substitution inincludeandexcludepatterns (match/skip cases for each)${staged}variable in args with static include pattern (match and no-match cases)--argsis supplied but pattern contains no${args}Type of change
Checklist
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.