Java 忽略在推送操作失败时推送到远程存储库的Git notes

Java 忽略在推送操作失败时推送到远程存储库的Git notes,java,git,github,jgit,Java,Git,Github,Jgit,我正在使用jgitapi,并使用GitServlet实现了我自己的git存储库 现在,在receivepack.setPostReceiveHook上,我在内部执行一些操作。如果推送失败,会发生什么情况?仍然推送音符。我需要确保推送错误,我也不应该推送笔记 这是我的示例receivepack.setPostReceiveHoo代码 receivepack.setPostReceiveHook(new PostReceiveHook() { public void

我正在使用jgitapi,并使用GitServlet实现了我自己的git存储库

现在,在
receivepack.setPostReceiveHook上,我在内部执行一些操作。如果推送失败,会发生什么情况?仍然推送音符。我需要确保推送错误,我也不应该推送笔记

这是我的示例receivepack.setPostReceiveHoo代码

receivepack.setPostReceiveHook(new PostReceiveHook() {
                public void onPostReceive(ReceivePack rp, Collection<ReceiveCommand> commands) {
                    try {                           
                        System.out.println("Inside setPostReceiveHook ========>> ");
                        if (_resName.contains("smp") || _resName.contains("cfg")) {
                            System.out.println("Inside setPostReceiveHook  with res_nm : ========>> " + _resName);
                            System.out.println("pushing to all nodes as this is master");
                            SMPPushOperation.pushToPeers(rp, db.getDirectory().getAbsolutePath(),
                                    CFG_GIT_REPO_URL);
                        }
                    } catch (Exception e) {
                        receivepack.sendError("Unable to push... ");
                    }
                }

            });
            return receivepack;
当我查看我的git存储库时,我可以看到注释正在被推送。在上面的代码中,我确实发送了错误消息

如何避免在推送失败时推送笔记


请说明

我以前的回答是错误的。在深入研究JGit的源代码之后,我看到post-receive钩子只为Result.OK命令触发。请参阅,因此在推送失败时不应推送注释。错误不是来自你的post接收钩子,它一定是其他原因…我之前的回答是错误的。在深入研究JGit的源代码之后,我看到post-receive钩子只为Result.OK命令触发。请参阅,因此在推送失败时不应推送注释。这个bug不是来自你的post接收钩子,它一定是其他东西。。。
git push https://sohanb.sys.net:8443/gitcontainer/demo-cfg refs/notes/*