sirosen / texthooks

pre-commit hooks for checking text file contents
Other
17 stars 3 forks source link

macro-expand with branch support #38

Closed all4innov closed 1 year ago

all4innov commented 1 year ago

@sirosen Is it possible to use different macro-expand based on branches? eg:

sirosen commented 1 year ago

It isn't currently possible with the way that the hook is written.

Two notes:

  1. you have to specify a prefix to do the macro replacement
  2. the only replacement available is the captured suffix from a match ($VALUE)

env isn't really a valid replaceable string for the way the hook is written. The hook will look for {prefix}{rest-of-word}. If you specified env as a prefix, then it would match envfoo, env100, but not env.

I'm willing to entertain this idea if you have a clear idea of an interface which fits with the existing hook or a distinct hook which serves this purpose. But this seems pretty far outside of the scope of the current fixer, which is basically this 3-line function packaged to be applicable as a pre-commit hook.

sirosen commented 1 year ago

Coming back to this issue and looking at it again, I'm going to go ahead and say no. I could maybe be convinced to reconsider, but I require convincing.