It takes a list of references that are being pushed from stdin (...)
The main ones are oldrev, newrev, ref, and they're commonly accessed this way:
read oldrev newrev ref
# Do something with those variables
The issue I encountered was: when running mdpo locally, everything would work,
but when on the Git hook on the server, mdpo would emit empty files. It wasn't
immediatelly obvious because the call to mdpo was deep in a series of sh script
calls, but I got a minimal reproducible example working.
I believe the cause is that the sys.stdin.isatty() check on __main__ is
getting more precedence than the positional interpretation of
GLOB_OR_CONTENT.
The behaviour I expected to encounter is the opposite, and when given a
positional argument, it supersedes the check of being invoked directly or
inside a pipe. Take cat, for example:
$ echo 'the content' > f.txt
$ cat f.txt
the content
$ echo | cat f.txt
the content
$ echo | cat -
$ echo | cat
I didn't investigate whether this is an issue with the argparse library or
with its usage in __main__, though, but I think the problem is restricted to
the code region.
As you can see above, the way I found around this issue was to always feed the
input to mdpo via STDIN, using md2po < f instead of md2po f, but I believe
that this is not the intended behaviour.
I've encountered this issue when running a Git
post-receive
hook an a server.On such hook, Git does a little preparation, setting some environment variables and also providing some values via STDIN. From https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks:
The main ones are
oldrev
,newrev
,ref
, and they're commonly accessed this way:The issue I encountered was: when running mdpo locally, everything would work, but when on the Git hook on the server, mdpo would emit empty files. It wasn't immediatelly obvious because the call to mdpo was deep in a series of sh script calls, but I got a minimal reproducible example working.
Sample interactive session:
Extracted steps to reproduce:
I believe the cause is that the
sys.stdin.isatty()
check on__main__
is getting more precedence than the positional interpretation ofGLOB_OR_CONTENT
.The behaviour I expected to encounter is the opposite, and when given a positional argument, it supersedes the check of being invoked directly or inside a pipe. Take
cat
, for example:I didn't investigate whether this is an issue with the
argparse
library or with its usage in__main__
, though, but I think the problem is restricted to the code region.As you can see above, the way I found around this issue was to always feed the input to mdpo via STDIN, using
md2po < f
instead ofmd2po f
, but I believe that this is not the intended behaviour.WDYT?