- function updateHook($owner, $repo) {
- $this->github->readRepo("$owner/$repo")->then(function($result) {
- list($repo) = $result;
- $call = new ListHooks($this->github, ["repo" => $repo->full_name]);
- $this->github->queue($call)->then(function($result) use($repo, $call) {
- list($repo->hooks) = $result;
- if (($hook = $this->github->checkRepoHook($repo))) {
- $hook_conf = $this->app->getRequest()->getForm();
- $this->github->updateRepoHook($repo->full_name, $hook->id, $hook_conf)->then(function($hook_result) use($repo, $hook, $result, $call) {
- list($changed_hook) = $hook_result;
- foreach ($changed_hook as $key => $val) {
- $hook->$key = $val;
- }
- $call->saveToCache($result);
- $this->redirectBack($repo->full_name);
- });
- }
- });
+ 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();