@@ -37,40 +37,42 @@ class PullModel extends AbstractModel
3737 * @var array
3838 * @since 2.0
3939 */
40- protected $ nonProductionFolders = array (
41- 'build ' ,
42- 'docs ' ,
43- 'installation ' ,
44- 'tests ' ,
45- '.github ' ,
46- );
40+ protected $ nonProductionFolders
41+ = array (
42+ 'build ' ,
43+ 'docs ' ,
44+ 'installation ' ,
45+ 'tests ' ,
46+ '.github ' ,
47+ );
4748
4849 /**
4950 * Array containing non-production files
5051 *
5152 * @var array
5253 * @since 2.0
5354 */
54- protected $ nonProductionFiles = array (
55- '.drone.yml ' ,
56- '.gitignore ' ,
57- '.php_cs ' ,
58- '.travis.yml ' ,
59- 'README.md ' ,
60- 'build.xml ' ,
61- 'composer.json ' ,
62- 'composer.lock ' ,
63- 'phpunit.xml.dist ' ,
64- 'robots.txt.dist ' ,
65- 'travisci-phpunit.xml ' ,
66- 'LICENSE ' ,
67- 'RoboFile.dist.ini ' ,
68- 'RoboFile.php ' ,
69- 'codeception.yml ' ,
70- 'jorobo.dist.ini ' ,
71- 'manifest.xml ' ,
72- 'crowdin.yaml ' ,
73- );
55+ protected $ nonProductionFiles
56+ = array (
57+ '.drone.yml ' ,
58+ '.gitignore ' ,
59+ '.php_cs ' ,
60+ '.travis.yml ' ,
61+ 'README.md ' ,
62+ 'build.xml ' ,
63+ 'composer.json ' ,
64+ 'composer.lock ' ,
65+ 'phpunit.xml.dist ' ,
66+ 'robots.txt.dist ' ,
67+ 'travisci-phpunit.xml ' ,
68+ 'LICENSE ' ,
69+ 'RoboFile.dist.ini ' ,
70+ 'RoboFile.php ' ,
71+ 'codeception.yml ' ,
72+ 'jorobo.dist.ini ' ,
73+ 'manifest.xml ' ,
74+ 'crowdin.yaml ' ,
75+ );
7476
7577 /**
7678 * The namespace mapper
@@ -522,7 +524,6 @@ private function saveAppliedPatch(int $id, array $fileList, string $sha = null):
522524 */
523525 private function applyWithGitHub (int $ id ): bool
524526 {
525- // Get the Github object
526527 $ github = Helper::initializeGithub ();
527528
528529 $ pull = $ this ->retrieveGitHubData ($ github , $ id );
@@ -534,12 +535,7 @@ private function applyWithGitHub(int $id): bool
534535
535536 try
536537 {
537- $ filesResponse = $ github ->getFilesForPullRequest (
538- $ this ->getState ()->get ('github_user ' ),
539- $ this ->getState ()->get ('github_repo ' ),
540- $ id
541- );
542- $ files = json_decode ($ filesResponse ->body , false );
538+ $ files = $ this ->getFiles ($ id , 1 );
543539 }
544540 catch (UnexpectedResponse $ exception )
545541 {
@@ -634,7 +630,7 @@ private function applyWithGitHub(int $id): bool
634630 // We only create a backup if the file already exists
635631 if ($ file ->action === 'deleted '
636632 || (file_exists (JPATH_ROOT . '/ ' . $ file ->filename )
637- && $ file ->action === 'modified ' )
633+ && $ file ->action === 'modified ' )
638634 || (file_exists (JPATH_ROOT . '/ ' . $ file ->originalFile ) && $ file ->action === 'renamed ' ))
639635 {
640636 $ filename = $ file ->action === 'renamed ' ? $ file ->originalFile : $ file ->filename ;
@@ -710,6 +706,49 @@ private function applyWithGitHub(int $id): bool
710706 return true ;
711707 }
712708
709+ /**
710+ * Get all files from Github.
711+ *
712+ * @param int $id The pull ID
713+ * @param int $page THhe page umber to process
714+ * @param array $files The list of files retrieved from Github
715+ *
716+ * @return array LIst of files to process.
717+ *
718+ * @since 4.2.0
719+ */
720+ private function getFiles (int $ id , int $ page , array $ files = []): array
721+ {
722+ $ github = Helper::initializeGithub ();
723+
724+ $ filesResponse = $ github ->getFilesForPullRequest (
725+ $ this ->getState ()->get ('github_user ' ),
726+ $ this ->getState ()->get ('github_repo ' ),
727+ $ id ,
728+ $ page
729+ );
730+
731+ $ files = array_merge ($ files , json_decode ($ filesResponse ->getBody (), false ));
732+ $ lastPage = 1 ;
733+
734+ preg_match (
735+ '/(\?page=[0-9]{1,3}>; rel=\"last\")/ ' , $ filesResponse ->getHeaders ()['link ' ][0 ], $ matches
736+ );
737+
738+ if ($ matches && isset ($ matches [0 ]))
739+ {
740+ preg_match ('/\d+/ ' , $ matches [0 ], $ pages );
741+ $ lastPage = (int ) $ pages [0 ];
742+ }
743+
744+ if ($ page <= $ lastPage )
745+ {
746+ $ files = $ this ->getFiles ($ id , ++$ page , $ files );
747+ }
748+
749+ return $ files ;
750+ }
751+
713752 /**
714753 * Parse the list of modified files from a pull request
715754 *
0 commit comments