mutating affectedFiles on prepush hook #447
Replies: 5 comments 2 replies
-
@tomdavidson Before I dig further, maybe I missed it, but what exactly are you trying to solve? So you get into a dirty state, are you trying to use this file list to |
Beta Was this translation helpful? Give feedback.
-
Thoughts about adding a MOON_AFFECTEDFILES var to the task env? The new affectedFiles feature works perfectly, as is, for running unit tests on a prepush hook. |
Beta Was this translation helpful? Give feedback.
-
@tomdavidson The For the env var, I'm curious how you'd access it? It'll be scoped to the child process and wouldn't be accessible from the hook file itself. You'll need to pass |
Beta Was this translation helpful? Give feedback.
-
Ahh thanks for As for env var, I think it could need to be consistent with envFile or just like the other MOON_ENVVARS Im going to end up running a script, parsing args to get the list of files, processing each one, writting it back with the captured file name. Having the env var would get me out for the arg parsing which isnt that big of a deal but I think it could get away with something like prepush:
command: bash -c ' eslint $FILES && prettier $FILES && git add $FILES' # or loop and pipe if thats faster than the io
I think I just need to separate the args and set the var in script and then I can do the same without any change to moon. |
Beta Was this translation helpful? Give feedback.
-
Yeah sounds good. I can add the env var real quick, let me take a look at feasibility. 👍 |
Beta Was this translation helpful? Give feedback.
-
My workflows squash merge so individual commits in a working branch do not really matter other than for the review. Formatting and complex linting on every commit is troublesome, especially when its expected to fail. The objective of my prepush githook tasks is to avoid waiting for 5-20min to learn of a simple defect via ci runner and to avoid formatting noise but to avoid additional obstacles of just failing when it could be auto resolved.
with a prepush hook such as
I will end up with git in a dirty state. Maybe dprint will be fast enough to do this on a precommit but prettier sure aint and some eslint rules are not.
Withe the awesome affectedFiles being appended to the args list, I should b able to have a script capture a list of the files to feed into additional git cmds. Unfortunately, Ill have to identify which args are files. I understand the token for the affectedFiles was not a feasible direction at this time. What about MOON_AFFECTED_FILES env var?
I also could just use
moon query
orgit diff
CHANGED_FILES=$(git diff ....)
but then I do not have the workspace context and I need eslint to run in the workspace scope not a global scope.Do you have a suggestion?
Beta Was this translation helpful? Give feedback.
All reactions