From 0e74aaefe7815820178c5957e71ef5d752d8d83d Mon Sep 17 00:00:00 2001
From: Lukas Reschke <lukas@statuscode.ch>
Date: Thu, 22 Sep 2016 11:40:00 +0200
Subject: [PATCH] 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>
---
 build/signed-off-checker.php | 29 +++++++----------------------
 1 file changed, 7 insertions(+), 22 deletions(-)

diff --git a/build/signed-off-checker.php b/build/signed-off-checker.php
index d97f4cf48b7..2a9df75b45c 100644
--- a/build/signed-off-checker.php
+++ b/build/signed-off-checker.php
@@ -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)) {
-- 
GitLab