解读 Heroku “git Push”常规“git push”的输出输出错误
目前,我解析 git push -q 的 STDERR 输出,以向用户呈现任何 git push 错误。大多数时候这都非常有效。然而,当推送到 Heroku 时,它们的预接收挂钩也会将服务器状态和应用程序状态输出到 STDERR。
我基本上只是在寻找一种简单的方法来区分输出是否实际上是来自 git 的错误与无关的 Heroku 数据。我尝试检查是否存在“---->
”前缀,但并非所有 Heroku 输出都有它。我还考虑过检查 STDERR 字符串中的“fatal:
”和“ssh:
”,但这似乎非常脆弱。我找不到任何文档说明每个 git 错误都以 ***:
为前缀
发送到 STDERR 的实际 Git 错误:
ssh: Could not resolve hostname heroku.com: nodename nor servname provided, or not known
fatal: The remote end hung up unexpectedly
典型的 Heroku 状态:
-----> Heroku receiving push
-----> Rack app detected
-----> Gemfile detected, running Bundler version 1.0.3
All dependencies are satisfied
Compiled slug size is 8.4MB
-----> Launching.... done
http://XXXXXXX.com deployed to Heroku
有没有人有更好的方法来完成仅识别真正的 git 错误?
Currently I parse STDERR output from git push -q
to present any git push
errors to the user. This works wonderfully most of the time. However when pushing to Heroku, their pre-receive hook outputs the status of the server and application status to STDERR as well.
I am basically just looking for an easy way to differentiate whether the output is actually errors from git vs extraneous Heroku data. I've tried checking for the presence of a "---->
" prefix, but not all Heroku output has it. I also thought of checking for "fatal:
" and "ssh:
" in the STDERR string, but that seems very brittle. And I couldn't find any documentation that every git error is prefixed with ***:
Actual Git Error sent to STDERR:
ssh: Could not resolve hostname heroku.com: nodename nor servname provided, or not known
fatal: The remote end hung up unexpectedly
Typical Heroku Status:
-----> Heroku receiving push
-----> Rack app detected
-----> Gemfile detected, running Bundler version 1.0.3
All dependencies are satisfied
Compiled slug size is 8.4MB
-----> Launching.... done
http://XXXXXXX.com deployed to Heroku
Does anyone have any ideas of a better way to accomplish identifying only the real git errors?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据 Heroku 的说法:截至目前,还没有一种万无一失的方法来区分 Heroku 输出和 Git 输出。但他们正在努力标准化其输出格式。
因此,这主要是寻找最常见元素的问题。
According to Heroku: as of right now, there is no bullet-proof way to differentiate Heroku output from Git output. But they are working on standardizing their output format.
So it's mostly a matter of looking for the most common elements.