Skip to content
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

ISSUE-394: expand patterns with brace expansion to avoid some matching issues #395

Merged
merged 1 commit into from
May 14, 2023

Conversation

mrmlnc
Copy link
Owner

@mrmlnc mrmlnc commented May 13, 2023

What is the purpose of this pull request?

Solves some of the problems with matching patterns containing brace expansion. Primary solves the problem when the pattern has duplicate slashes after it is expanded (#394), or the micromatch package does not correctly generate a regular expression (#365).

What changes did you make? (Give an overview)

Expand patterns with brace expansions once at the very beginning of pattern processing when generating tasks.

This solution can lead to a slight slowdown in matching in the case of a large set of patterns after expansion. Problems with performance should deal with the issues as they come.

fg.sync('fixtures/{.directory,first,first/nested,second,second/nested,third,third/library,third/library/a,third/library/b}/*')

// PR: 6ms
// Master: 5.5ms
fg.generateTasks
fg.generateTasks(/* … */);
// Master
[
  {
    dynamic: true,
    positive: [
      'fixtures/{.directory,first,first/nested,second,second/nested,third,third/library,third/library/a,third/library/b}/*'
    ],
    negative: [],
    base: 'fixtures',
    patterns: [
      'fixtures/{.directory,first,first/nested,second,second/nested,third,third/library,third/library/a,third/library/b}/*'
    ]
  }
]

// PR
[
  {
    dynamic: true,
    positive: [
      'fixtures/first/*'
    ],
    negative: [],
    base: 'fixtures/first',
    patterns: [
      'fixtures/first/*'
    ]
  },
  {
    dynamic: true,
    positive: [
      'fixtures/third/*'
    ],
    negative: [],
    base: 'fixtures/third',
    patterns: [
      'fixtures/third/*'
    ]
  },
  {
    dynamic: true,
    positive: [
      'fixtures/second/*'
    ],
    negative: [],
    base: 'fixtures/second',
    patterns: [
      'fixtures/second/*'
    ]
  },
  {
    dynamic: true,
    positive: [
      'fixtures/.directory/*'
    ],
    negative: [],
    base: 'fixtures/.directory',
    patterns: [
      'fixtures/.directory/*'
    ]
  },
  {
    dynamic: true,
    positive: [
      'fixtures/first/nested/*'
    ],
    negative: [],
    base: 'fixtures/first/nested',
    patterns: [
      'fixtures/first/nested/*'
    ]
  },
  {
    dynamic: true,
    positive: [
      'fixtures/second/nested/*'
    ],
    negative: [],
    base: 'fixtures/second/nested',
    patterns: [
      'fixtures/second/nested/*'
    ]
  },
  {
    dynamic: true,
    positive: [
      'fixtures/third/library/*'
    ],
    negative: [],
    base: 'fixtures/third/library',
    patterns: [
      'fixtures/third/library/*'
    ]
  },
  {
    dynamic: true,
    positive: [
      'fixtures/third/library/a/*'
    ],
    negative: [],
    base: 'fixtures/third/library/a',
    patterns: [
      'fixtures/third/library/a/*'
    ]
  },
  {
    dynamic: true,
    positive: [
      'fixtures/third/library/b/*'
    ],
    negative: [],
    base: 'fixtures/third/library/b',
    patterns: [
      'fixtures/third/library/b/*'
    ]
  }
]

In the future, we can learn to forcibly group patterns into groups if one base directory has 2+ nested directories in adjacent patterns.

@mrmlnc mrmlnc force-pushed the ISSUE-394_brace_expansion branch from 17e826a to 24e36e2 Compare May 13, 2023 20:07
@mrmlnc mrmlnc added this to the 3.3.0 milestone May 13, 2023
@mrmlnc mrmlnc force-pushed the ISSUE-394_brace_expansion branch 4 times, most recently from e8416f9 to 1ba65a9 Compare May 14, 2023 09:03
@mrmlnc mrmlnc force-pushed the ISSUE-394_brace_expansion branch from 1ba65a9 to 21c9448 Compare May 14, 2023 09:17
@mrmlnc mrmlnc marked this pull request as ready for review May 14, 2023 09:20
@mrmlnc mrmlnc merged commit b76c850 into master May 14, 2023
@mrmlnc mrmlnc deleted the ISSUE-394_brace_expansion branch May 14, 2023 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant