/** * @param array $data * @param string $entityType */ public function storeData($data, $entityType) { parent::storeData($data, $entityType); $fileName = $this->_getEntityFilename($entityType); $git = new VersionControl_Git($this->_getStorageDirectory()); $fileName = substr($fileName, strlen($this->_getStorageDirectory())); try { $status = $git->getRevListFetcher(); $status->setSubCommand('status'); $status->addArgument('--porcelain'); $status_result = $status->execute(); foreach (explode("\n", $status_result) as $status_line) { $git_status = substr($status_line, 1, 1); $git_file = substr($status_line, 3); if (in_array($git_status, array('M', 'A'))) { $commit = $git->getCommand('commit'); $commit->setOption('message', 'current "' . $entityType . '" content'); $commit->addArgument($fileName); $commit->execute(); } } } catch (VersionControl_Git_Exception $e) { //if ( strpos($e->getMessage(), 'nothing to commit') === false ) //{ throw $e; //} } }
/** * @param array $data * @param string $entityType * @throws VersionControl_SVN_Exception on error */ public function storeData($data, $entityType) { parent::storeData($data, $entityType); $fileName = $this->_getEntityFilename($entityType); $svnStatus = VersionControl_SVN::factory('status'); $status = $svnStatus->run(array($fileName)); if (isset($status['target']) and isset($status['target'][0]) and isset($status['target'][0]['entry']) and is_array($status['target'][0]['entry'])) { foreach ($status['target'][0]['entry'] as $entry) { switch ($entry['wc-status']['item']) { case 'unversioned': $svnAdd = VersionControl_SVN::factory('add'); $svnAdd->run(array($fileName)); case 'modified': case 'added': $svnCommit = VersionControl_SVN::factory('ci'); $svnCommit->run(array($fileName), array('m' => escapeshellarg('current "' . $entityType . '" content'))); } } } }