From: Jitendra Purohit Date: Tue, 4 Jul 2017 09:11:31 +0000 (+0530) Subject: CRM-20809 : Create .gitignore file to ignore extensions cache files X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=5c55a24b8d9a8161cad9829eafbed7517af5ab04;p=civicrm-core.git CRM-20809 : Create .gitignore file to ignore extensions cache files --- diff --git a/CRM/Extension/System.php b/CRM/Extension/System.php index 0601939855..c8ea7e1274 100644 --- a/CRM/Extension/System.php +++ b/CRM/Extension/System.php @@ -225,12 +225,31 @@ class CRM_Extension_System { $cacheDir = NULL; if ($this->getDefaultContainer()) { $cacheDir = $this->getDefaultContainer()->getBaseDir() . DIRECTORY_SEPARATOR . 'cache'; + $this->createGitIgnoreForCacheFiles($this->getDefaultContainer()->getBaseDir()); } $this->browser = new CRM_Extension_Browser($this->getRepositoryUrl(), '', $cacheDir); } return $this->browser; } + /** + * Create .gitignore to remove cache dir. + * + * @param string $extPath + */ + public function createGitIgnoreForCacheFiles($extPath) { + if (!empty($extPath)) { + $path = $extPath . DIRECTORY_SEPARATOR . '.gitignore'; + if (file_exists($path)) { + //Return if cache dir is already ignored. + if (in_array('cache', explode("\n", file_get_contents($path)))) { + return; + } + } + file_put_contents($path, "cache\n", FILE_APPEND); + } + } + /** * Get the service for loading code from remotely-available extensions * diff --git a/tools/extensions/.gitignore b/tools/extensions/.gitignore index 05d4332dde..8ca96b7556 100644 --- a/tools/extensions/.gitignore +++ b/tools/extensions/.gitignore @@ -3,3 +3,4 @@ civisualize civivolunteer org.civicoop.civirules org.civicrm.angularprofiles +cache