@Override public boolean remove(Object url) { try { String _url = ((URL)url).toExternalForm(); for (GHHook h : getHooks()) { if (h.getName().equals("web") && h.getConfig().get("url").equals(_url)) { h.delete(); return true; } } return false; } catch (IOException e) { throw new GHException("Failed to update post-commit hooks",e); } } };
/** * Verify if exists a webhook by its URL. */ private static boolean existsHook(GHOrganization org, String url) throws IOException { for (GHHook hook : org.getHooks()) { if (hook.getConfig().get("url").equals(url)) { return true; } } return false; }
protected boolean applyNullSafe(@Nonnull GHHook hook) { try { hook.delete(); return true; } catch (IOException e) { throw new GHException("Failed to delete post-commit hook", e); } } };
/** * @see <a href="https://developer.github.com/v3/repos/hooks/#ping-a-hook">Ping hook</a> */ public void ping() throws IOException { new Requester(getRoot()).method("POST").to(getApiRoute() + "/pings"); }
@Override protected Iterable<GHEvent> applyNullSafe(@Nonnull GHHook input) { return input.getEvents(); } };
/** * Deletes this hook. */ public void delete() throws IOException { new Requester(getRoot()).method("DELETE").to(getApiRoute()); }
@Override public boolean remove(Object url) { try { String _url = ((URL)url).toExternalForm(); for (GHHook h : getHooks()) { if (h.getName().equals("web") && h.getConfig().get("url").equals(_url)) { h.delete(); return true; } } return false; } catch (IOException e) { throw new GHException("Failed to update post-commit hooks",e); } } };
/** * Deletes this hook. */ public void delete() throws IOException { new Requester(getRoot()).method("DELETE").to(getApiRoute()); }
@Override public boolean remove(Object url) { try { String _url = ((URL)url).toExternalForm(); for (GHHook h : getHooks()) { if (h.getName().equals("web") && h.getConfig().get("url").equals(_url)) { h.delete(); return true; } } return false; } catch (IOException e) { throw new GHException("Failed to update post-commit hooks",e); } } };
/** * @see <a href="https://developer.github.com/v3/repos/hooks/#ping-a-hook">Ping hook</a> */ public void ping() throws IOException { new Requester(getRoot()).method("POST").to(getApiRoute() + "/pings"); }
private boolean hookExist() throws IOException { GHRepository ghRepository = getGitHubRepo(); if (ghRepository == null) { throw new IOException("Unable to get repo [ " + reponame + " ]"); } for (GHHook h : ghRepository.getHooks()) { if (!"web".equals(h.getName())) { continue; } if (!getHookUrl().equals(h.getConfig().get("url"))) { continue; } return true; } return false; }