tach
tach copied to clipboard
Continue #234
Rebased to main and created an abstraction for pattern matching.
WIP:
tach modshowsnothing to repeat at position 0(on #234 also) because ofrebeing used in some python files- Have to include a key in project config, which says what pattern matching to use, regex or glob. Can support both or decide to deprecate regex, how should we proceed?
imo we can have pattern_matching = "globs" by default added in config and if someone wants to use regex, they can change it to pattern_matching = "regex"
@sparshg if there's only going to be two types of pattern_matching, I think a bool is sufficient.
I'd also prefer glob to be the default, but we don't want to break any existing installations. I think if we're writing a brand new tach config it's fine to set it to glob, but if we detect or are working with an existing config, we should not break the existing behavior.
Because of this, it might be easier to just default to regex for now, and create a better migration mechanism in the future. What do you think?
Makes sense, I will default it to do a use_regex_matching = True by default for now
Ready to merge, can show a warning if use_regex_matching isn't detected in the config, stating that default behaviour would be matching globs from the next major release
--exclude cli parameter doesn't work, I will fix that before I can do validation
I have made some changes, --exclude parameter now works. exclude_paths parameter gets extended with project_config.exclude only inside cli.py and also gets validated there.
Example validation error:
Invalid regex pattern: **/pycache/**. If you meant to use glob matching, set 'use_regex_matching' to false in your .toml file.
@sparshg thank you! Let me know when you're ready for another review and I'll do some testing and we can get this deployed π₯
Ready to review,
in 2e17a87 I had tried to fix --exclude by adding cli excludes to project config.
62cf8a5 reverts this decision, because excludes from project config should be imo immutable. Also, did a fixup to revert some other bad changes in 760f507
lmk what you think about current approach.
The pattern validation is not done in tach_check_external(). It does not take --exclude from cli, is this meant to be there? I will handle validation accordingly then.