@@ -30,6 +30,14 @@ class PatchtesterModelPull extends JModelLegacy
3030 */
3131 protected $ github ;
3232
33+ /**
34+ * Array containing top level non-production folders
35+ *
36+ * @var array
37+ * @since 2.0
38+ */
39+ protected $ nonProductionFolders = array ('build ' , 'docs ' , 'installation ' , 'tests ' );
40+
3341 /**
3442 * Object containing the rate limit data
3543 *
@@ -51,7 +59,7 @@ public function __construct($config = array())
5159
5260 // Set up the JHttp object
5361 $ options = new JRegistry ;
54- $ options ->set ('userAgent ' , 'JPatchTester/1 .0 ' );
62+ $ options ->set ('userAgent ' , 'JPatchTester/2 .0 ' );
5563 $ options ->set ('timeout ' , 120 );
5664
5765 $ this ->transport = JHttpFactory::getHttp ($ options , 'curl ' );
@@ -153,6 +161,21 @@ protected function parsePatch($patch)
153161 if (strpos ($ line , '@@ ' ) === 0 )
154162 {
155163 $ state = 0 ;
164+
165+ /*
166+ * Check if the patch tester is running in a production environment
167+ * If so, do not patch certain files as errors will be thrown
168+ */
169+ if (!file_exists (JPATH_ROOT . '/installation/CHANGELOG ' ))
170+ {
171+ $ filePath = explode ('/ ' , $ file ->new );
172+
173+ if (in_array ($ filePath [0 ], $ this ->nonProductionFolders ))
174+ {
175+ continue ;
176+ }
177+ }
178+
156179 $ files [] = $ file ;
157180 }
158181
@@ -189,6 +212,13 @@ public function apply($id)
189212
190213 $ files = $ this ->parsePatch ($ patch );
191214
215+ if (!$ files )
216+ {
217+ JFactory::getApplication ()->enqueueMessage (JText::_ ('COM_PATCHTESTER_NO_FILES_TO_PATCH ' , 'message ' ));
218+
219+ return true ;
220+ }
221+
192222 foreach ($ files as $ file )
193223 {
194224 if ($ file ->action == 'deleted ' && !file_exists (JPATH_ROOT . '/ ' . $ file ->old ))
0 commit comments