开发者

Why doesn't my mercurial pre-commit hook work in MinGW

I have a pre-commit hook in my .hgrc file which checks if more than 5MB of files will be added to the repository. The hook is:

pre-commit.added-files-too-large = tes开发者_如何学运维t 5000 -gt `hg status --added --no-status --print0 | xargs --null ls -lk | awk \'{sum += $5} END {print sum}\'`

This works fine on Linux (using bash) but doesn't work on MinGW. If I simply run the same command from the MinGW shell command line it works as expected.

The error message is

test: invalid integer ``hg'

I suspect that the error is something to do with how things are quoted but I've tried lots of combinations (including changing the backticks to $()) and I can't seem to find the correct answer.

Any help or pointers would be greatly appreciated.


My guess is that the embedded script prints an error of some kind so test sees a string instead of a number.

Run the command hs status... from the command line to see what it prints.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜