-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from hirak/feature/improve-scrutinizer-score-2
Improve scrutinizer score
- Loading branch information
Showing
17 changed files
with
468 additions
and
363 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
/* | ||
* hirak/prestissimo | ||
* @author Hiraku NAKANO | ||
* @license MIT https://github.com/hirak/prestissimo | ||
*/ | ||
namespace Hirak\Prestissimo\Aspects; | ||
|
||
use Composer\IO; | ||
use Composer\Config as CConfig; | ||
use Composer\Util; | ||
use Composer\Downloader; | ||
|
||
/** | ||
* Simple Container for http-get request | ||
* GitHub edition | ||
*/ | ||
class GitHubRequest extends HttpGetRequest | ||
{ | ||
public function processRFSOption(array $options) | ||
{ | ||
if (isset($options['github-token'])) { | ||
$this->query['access_token'] = $options['github-token']; | ||
} | ||
} | ||
|
||
public function getCurlOpts() | ||
{ | ||
$curlOpts = parent::getCurlOpts(); | ||
return $curlOpts; | ||
} | ||
|
||
public function promptAuth(HttpGetResponse $res, CConfig $config, IO\IOInterface $io) | ||
{ | ||
$httpCode = $res->info['http_code']; | ||
$message = "\nCould not fetch {$this->getURL()}, please create a GitHub OAuth token "; | ||
if (404 === $httpCode) { | ||
$message .= 'to access private repos'; | ||
} else { | ||
$message .= 'to go over the API rate limit'; | ||
} | ||
$github = new Util\GitHub($io, $config, null); | ||
if ($github->authorizeOAuth($this->origin)) { | ||
return true; | ||
} | ||
if ($io->isInteractive() && | ||
$github->authorizeOAuthInteractively($this->origin, $message)) { | ||
return true; | ||
} | ||
|
||
throw new Downloader\TransportException( | ||
"Could not authenticate against $this->origin", | ||
401 | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
/* | ||
* hirak/prestissimo | ||
* @author Hiraku NAKANO | ||
* @license MIT https://github.com/hirak/prestissimo | ||
*/ | ||
namespace Hirak\Prestissimo\Aspects; | ||
|
||
use Composer\IO; | ||
use Composer\Config as CConfig; | ||
use Composer\Composer; | ||
use Composer\Downloader; | ||
|
||
/** | ||
* Simple Container for http-get request | ||
* GitLab edition | ||
*/ | ||
class GitLabRequest extends HttpGetRequest | ||
{ | ||
public function processRFSOption(array $options) | ||
{ | ||
if (isset($options['gitlab-token'])) { | ||
$this->query['access_token'] = $options['gitlab-token']; | ||
} | ||
} | ||
|
||
public function getCurlOpts() | ||
{ | ||
$curlOpts = parent::getCurlOpts(); | ||
return $curlOpts; | ||
} | ||
|
||
public function promptAuth(HttpGetResponse $res, CConfig $config, IO\IOInterface $io) | ||
{ | ||
$httpCode = $res->info['http_code']; | ||
$message = "\nCould not fetch {$this->getURL()}, enter your $this->origin credentials "; | ||
if (401 === $httpCode) { | ||
$message .= 'to access private repos'; | ||
} else { | ||
$message .= 'to go over the API rate limit'; | ||
} | ||
$gitlab = new Util\GitLab($io, $config, null); | ||
if ($gitlab->authorizeOAuth($this->origin)) { | ||
return true; | ||
} | ||
if ($io->isInteractive() && | ||
$gitlab->authorizeOAuthInteractively($this->origin, $message)) { | ||
return true; | ||
} | ||
|
||
throw new Downloader\TransportException( | ||
"Could not authenticate against $this->origin", | ||
401 | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.