projects
/
pharext
/
pharext.org
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
use a 202 if the asset was already published
[pharext/pharext.org]
/
app
/
Github
/
API.php
diff --git
a/app/Github/API.php
b/app/Github/API.php
index d6990f257edf7fc80fa8c04961e4687d35df251d..e56ada1ecb3941079ddf9a176a07130cc08ccabd 100644
(file)
--- a/
app/Github/API.php
+++ b/
app/Github/API.php
@@
-49,7
+49,8
@@
class API
function __construct(Config $config, LoggerInterface $logger, Storage $tokens = null, Storage $cache = null) {
$this->logger = $logger;
$this->config = $config;
function __construct(Config $config, LoggerInterface $logger, Storage $tokens = null, Storage $cache = null) {
$this->logger = $logger;
$this->config = $config;
- $this->client = new Client;
+ $this->client = new Client("curl", "github");
+ $this->client->configure($config->http->configure->toArray());
$this->client->attach(new ClientObserver($logger));
$this->tokens = $tokens ?: new Storage\Session;
$this->cache = $cache;
$this->client->attach(new ClientObserver($logger));
$this->tokens = $tokens ?: new Storage\Session;
$this->cache = $cache;
@@
-168,6
+169,22
@@
class API
return $call($callback);
}
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);
function listHooks($repo, callable $callback) {
$call = new API\Hooks\ListHooks($this, compact("repo"));
return $call($callback);
@@
-207,7
+224,12
@@
class API
$call = new API\Releases\CreateRelease($this, compact("repo", "tag"));
return $call($callback);
}
$call = new API\Releases\CreateRelease($this, compact("repo", "tag"));
return $call($callback);
}
-
+
+ function publishRelease($repo, $id, $tag, callable $callback) {
+ $call = new API\Releases\PublishRelease($this, compact("repo", "id", "tag"));
+ return $call($callback);
+ }
+
function createReleaseAsset($url, $asset, $type, callable $callback) {
$call = new API\Releases\CreateReleaseAsset($this, compact("url", "asset", "type"));
return $call($callback);
function createReleaseAsset($url, $asset, $type, callable $callback) {
$call = new API\Releases\CreateReleaseAsset($this, compact("url", "asset", "type"));
return $call($callback);