Viewing File: /usr/local/cpanel/3rdparty/wpinstaller/src/WpDownloader/GitApi.php
<?php
namespace WpDownloader;
use WpDownloader\Log;
class GitApi extends HttpApi
{
public static $baseUrl = 'https://api.github.com';
protected static $logFile = 'git_api';
public static function getLatestCommitForBranch($owner, $repo, $branch=null)
{
$branch = $branch ?: 'master';
$response = self::apiRequest("/repos/$owner/$repo/branches/$branch");
if (empty($response['commit'])) {
throw new \Exception("Failed to retrieve commit data from API. Response was:".print_r($response, 1));
}
return $response['commit'];
}
public static function getDownloadUrl($owner, $repo, $branch=null, $format=null)
{
$branch = $branch ?: 'master';
$format = $format ?: 'zipball';
$apiUrl = self::buildApiUrl("/repos/$owner/$repo/$format/$branch", null);
Log::write("Resolving redirects on download URL {$apiUrl}");
$downloadUrl = self::resolveRedirect($apiUrl);
return $downloadUrl;
}
}
Back to Directory
File Manager