@@ -369,6 +369,22 @@ abstract public function getCommit(string $owner, string $repositoryName, string
369369 */
370370 abstract public function getLatestCommit (string $ owner , string $ repositoryName , string $ branch ): array ;
371371
372+ /**
373+ * Get a short-lived presigned URL to download the repository archive.
374+ *
375+ * @param string $owner Owner name of the repository
376+ * @param string $repositoryName Name of the repository
377+ * @param string $ref Branch, tag or commit to download (defaults to the default branch)
378+ * @param string $format Archive format, e.g. 'tarball' or 'zipball'
379+ * @return string Presigned download URL
380+ *
381+ * @throws Exception when the adapter does not implement it (opt-in, mirrors createCheckRun())
382+ */
383+ public function getRepositoryPresignedUrl (string $ owner , string $ repositoryName , string $ ref = '' , string $ format = 'tarball ' ): string
384+ {
385+ throw new Exception ('getRepositoryPresignedUrl() is not implemented for ' . $ this ->getName ());
386+ }
387+
372388 /**
373389 * Call
374390 *
@@ -379,11 +395,12 @@ abstract public function getLatestCommit(string $owner, string $repositoryName,
379395 * @param array<mixed> $params
380396 * @param array<string, string> $headers
381397 * @param bool $decode
398+ * @param bool $followRedirects When false, a redirect response is returned as-is instead of being followed
382399 * @return array<mixed>
383400 *
384401 * @throws Exception
385402 */
386- protected function call (string $ method , string $ path = '' , array $ headers = [], array $ params = [], bool $ decode = true )
403+ protected function call (string $ method , string $ path = '' , array $ headers = [], array $ params = [], bool $ decode = true , bool $ followRedirects = true )
387404 {
388405 $ headers = array_merge ($ this ->headers , $ headers );
389406 $ ch = curl_init ($ this ->endpoint . $ path . (($ method == self ::METHOD_GET && !empty ($ params )) ? '? ' . http_build_query ($ params ) : '' ));
@@ -423,7 +440,7 @@ protected function call(string $method, string $path = '', array $headers = [],
423440 curl_setopt ($ ch , CURLOPT_PATH_AS_IS , 1 );
424441 curl_setopt ($ ch , CURLOPT_CUSTOMREQUEST , $ method );
425442 curl_setopt ($ ch , CURLOPT_RETURNTRANSFER , 1 );
426- curl_setopt ($ ch , CURLOPT_FOLLOWLOCATION , true );
443+ curl_setopt ($ ch , CURLOPT_FOLLOWLOCATION , $ followRedirects );
427444 curl_setopt ($ ch , CURLOPT_USERAGENT , 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36 ' );
428445 curl_setopt ($ ch , CURLOPT_HTTPHEADER , $ headers );
429446 curl_setopt ($ ch , CURLOPT_CONNECTTIMEOUT , 0 );
0 commit comments