- function updateHook($owner, $repo) {
- $this->github->readRepo("$owner/$repo", function($repo) {
- $call = $this->github->listHooks($repo->full_name, function($hooks, $links) use($repo, &$call) {
- $repo->hooks = $hooks;
- if (($hook = $this->checkRepoHook($repo))) {
- $hook_conf = $this->app->getRequest()->getForm();
- $this->github->updateRepoHook($repo->full_name, $hook->id, $hook_conf, function($changed_hook) use($repo, $hook, $hooks, $links, &$call) {
- foreach ($changed_hook as $key => $val) {
- $hook->$key = $val;
- }
- $call->saveToCache([$hooks, $links]);
- $this->redirectBack($repo->full_name);
- });
- }
- });
- })->send();
+ function updateHook($repo_name) {
+ $listhooks = new ListHooks($this->github, ["repo" => $repo_name]);
+ return $this->github->queue($listhooks)->then(function($result) use($repo_name) {
+ list($hooks) = $result;
+
+ if (!($hook = $this->github->checkHook($hooks))) {
+ throw new \Exception("Hook is not set");
+ }
+
+ return $this->github->updateRepoHook($repo_name, $hook->id, $this->app->getRequest()->getForm());
+ })->then(function() use($listhooks) {
+ $listhooks->dropFromCache();
+ });