如何在没有错误的情况下提交任何内容?

编程入门 行业动态 更新时间:2024-10-09 10:19:23
本文介绍了如何在没有错误的情况下提交任何内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试编写一个结构脚本来执行 git commit ;但是,如果没有提交的内容,git将以 1 的状态退出。部署脚本将其视为不成功并退出。我确实希望检测到 提交失败的情况,所以我不能只为 git commit 失败提供结构忽略。我怎样才能允许空承诺失败被忽略,以便部署可以继续,但仍然捕获真正的提交失败时导致的错误?

def commit(): local(git add -p&&git commit)

git add -A git diff-index --quiet HEAD || git commit -m'bla'

编辑:修正了 git diff根据Holger的评论,命令

I'm trying to write a fabric script that does a git commit; however, if there is nothing to commit, git exits with a status of 1. The deploy script takes that as unsuccessful, and quits. I do want to detect actual failures-to-commit, so I can't just give fabric a blanket ignore for git commit failures. How can I allow empty-commit failures to be ignored so that deploy can continue, but still catch errors caused when a real commit fails?

def commit(): local("git add -p && git commit")

解决方案

Catch this condition beforehand by checking the exit code of git diff?

For example (in shell):

git add -A git diff-index --quiet HEAD || git commit -m 'bla'

EDIT: Fixed git diff command according to Holger's comment.

更多推荐

如何在没有错误的情况下提交任何内容?

本文发布于:2023-11-17 10:55:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1609790.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:情况下   错误   内容   如何在

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!