yet another github api refactoring
[pharext/pharext.org] / app / Github / API.php
index d6990f257edf7fc80fa8c04961e4687d35df251d..1c9ff7834e772a92cc8fb758bb8701bfaae6bf88 100644 (file)
@@ -168,6 +168,22 @@ class API
                return $call($callback);
        }
 
+       /**
+        * Check if the pharext webhook is set for the repo and return it
+        * @param object $repo
+        * @return stdClass hook
+        */
+       function checkRepoHook($repo) {
+               if ($repo->hooks) {
+                       foreach ($repo->hooks as $hook) {
+                               if ($hook->name === "web" && $hook->config->url === $this->config->hook->url) {
+                                       return $hook;
+                               }
+                       }
+               }
+               return null;
+       }
+
        function listHooks($repo, callable $callback) {
                $call = new API\Hooks\ListHooks($this, compact("repo"));
                return $call($callback);