Rely solely on GitHub API output

This doesn't download the whole git repository again which saves roughly 90 seconds in execution time on the test.

Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
This commit is contained in:
Lukas Reschke 2016-09-22 11:40:00 +02:00
parent 538fcf3d1f
commit 0e74aaefe7
No known key found for this signature in database
GPG Key ID: B9F6980CF6E759B1
1 changed files with 7 additions and 22 deletions

View File

@ -41,14 +41,6 @@ curl_setopt($ch, CURLOPT_USERAGENT, 'CI for Nextcloud (https://github.com/nextcl
$response = curl_exec($ch);
curl_close($ch);
shell_exec(
sprintf(
'cd %s && git fetch',
escapeshellarg($baseDir),
escapeshellarg($pullRequestNumber)
)
);
$decodedResponse = json_decode($response, true);
if(!is_array($decodedResponse) || count($decodedResponse) === 0) {
echo("Could not decode JSON response from GitHub API.\n");
@ -63,33 +55,26 @@ foreach($decodedResponse as $commit) {
echo("No SHA specified in $commit\n");
exit(1);
}
$commits[] = $commit['sha'];
if(!isset($commit['commit']['message'])) {
echo("No commit message specified in $commit\n");
exit(1);
}
$commits[$commit['sha']] = $commit['commit']['message'];
}
if(count($commits) < 1) {
echo("Could not read commits.\n");
exit(1);
}
$notSignedCommits = [];
foreach($commits as $commit) {
foreach($commits as $commit => $message) {
if($commit === '') {
continue;
}
$signOffMessage = false;
$commitMessageLines =
explode(
"\n",
shell_exec(
sprintf(
'cd %s && git rev-list --format=%%B --max-count=1 %s',
$baseDir,
$commit
)
)
);
$commitMessageLines = explode("\n", $message);
foreach($commitMessageLines as $line) {
if(preg_match('/^Signed-off-by: .* <.*@.*>$/', $line)) {