@@ -37,40 +37,42 @@ class PullModel extends AbstractModel
37
37
* @var array
38
38
* @since 2.0
39
39
*/
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
+ );
47
48
48
49
/**
49
50
* Array containing non-production files
50
51
*
51
52
* @var array
52
53
* @since 2.0
53
54
*/
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
+ );
74
76
75
77
/**
76
78
* The namespace mapper
@@ -522,7 +524,6 @@ private function saveAppliedPatch(int $id, array $fileList, string $sha = null):
522
524
*/
523
525
private function applyWithGitHub (int $ id ): bool
524
526
{
525
- // Get the Github object
526
527
$ github = Helper::initializeGithub ();
527
528
528
529
$ pull = $ this ->retrieveGitHubData ($ github , $ id );
@@ -534,12 +535,7 @@ private function applyWithGitHub(int $id): bool
534
535
535
536
try
536
537
{
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 );
543
539
}
544
540
catch (UnexpectedResponse $ exception )
545
541
{
@@ -634,7 +630,7 @@ private function applyWithGitHub(int $id): bool
634
630
// We only create a backup if the file already exists
635
631
if ($ file ->action === 'deleted '
636
632
|| (file_exists (JPATH_ROOT . '/ ' . $ file ->filename )
637
- && $ file ->action === 'modified ' )
633
+ && $ file ->action === 'modified ' )
638
634
|| (file_exists (JPATH_ROOT . '/ ' . $ file ->originalFile ) && $ file ->action === 'renamed ' ))
639
635
{
640
636
$ filename = $ file ->action === 'renamed ' ? $ file ->originalFile : $ file ->filename ;
@@ -710,6 +706,49 @@ private function applyWithGitHub(int $id): bool
710
706
return true ;
711
707
}
712
708
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
+
713
752
/**
714
753
* Parse the list of modified files from a pull request
715
754
*
0 commit comments