public function commit($message, $t = false) { $files = $this->_loadLevel($this->_dir); $commit = array(); foreach ($files as $index => $name) { $content = file_get_contents($this->_dir . '/' . $name); if (!isset($this->_filesAtLastCommit[$name])) { $commit[$name] = Versionning::createCommit('', $content, $this->_deletedLineMarker)['differences']; } else { $commit[$name] = Versionning::createCommit($this->_filesAtLastCommit[$name], $content, $this->_deletedLineMarker)['differences']; if (!count($commit[$name])) { unset($commit[$name]); } } } foreach ($this->_filesAtLastCommit as $name => $content) { if (array_search($name, $files) === false) { $commit[$name] = array('type' => 'deleted'); } } $this->_commits[] = array('files' => $commit, 'date' => date($this->_dateFormat), 'message' => $message, 'deletedLineMarker' => $this->_deletedLineMarker); $this->_filesAtLastCommit = array(); foreach ($files as $index => $name) { $this->_filesAtLastCommit[$name] = file_get_contents($this->_dir . '/' . $name); } return $this->_commits[count($this->_commits) - 1]; }
public function commit($message) { if (!is_string($message)) { return false; } $this->_commits[] = Versionning::createCommit($this->_contentAtLastCommit, $this->_content, $this->_deletedLineMarker, $message, $this->_dateFormat); $this->_contentAtLastCommit = $this->_content; }