/** Retrieves the currently configured hooks. */
 public List<GHHook> getHooks() throws IOException {
   List<GHHook> list =
       new ArrayList<GHHook>(
           Arrays.asList(
               root.retrieve()
                   .to(String.format("/repos/%s/%s/hooks", owner.login, name), GHHook[].class)));
   for (GHHook h : list) h.wrap(this);
   return list;
 }
 private List<URL> getPostCommitHooks() {
   try {
     List<URL> r = new ArrayList<URL>();
     for (GHHook h : getHooks()) {
       if (h.getName().equals("web")) {
         r.add(new URL(h.getConfig().get("url")));
       }
     }
     return r;
   } catch (IOException e) {
     throw new GHException("Failed to retrieve post-commit hooks", e);
   }
 }
 private boolean hookExist() throws IOException {
   GHRepository ghRepository = getGitHubRepo();
   for (GHHook h : ghRepository.getHooks()) {
     if (!"web".equals(h.getName())) {
       continue;
     }
     if (!getHookUrl().equals(h.getConfig().get("url"))) {
       continue;
     }
     return true;
   }
   return false;
 }
 @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);
   }
 }