private function checkReferencesForRevertedCommit(Commit $revertedCommit) { $changeInfo = $this->commitMessageParser->parse($revertedCommit->getMessage()); if ($changeInfo instanceof UntrackedChangeInfo) { return true; } foreach ($changeInfo->getChangeInfoList() as $subChangeInfo) { if ($subChangeInfo instanceof EntityChangeInfo && !$this->checkEntityReferences($subChangeInfo->getScope(), $subChangeInfo->getId(), $subChangeInfo->getParentId())) { return false; } } return true; }
/** * Returns an array of Commits based on {@link http://git-scm.com/docs/gitrevisions gitrevisions} * * @param string $options Options passed to git log * @param string $gitrevisions Empty by default, i.e., calling full 'git log' * @return Commit[] */ public function log($options = "", $gitrevisions = "") { $commitDelimiter = chr(29); $dataDelimiter = chr(30); $statusDelimiter = chr(31); $logCommand = "git log --pretty=format:\"|begin|%%H|delimiter|%%aD|delimiter|%%ar|delimiter|%%an|delimiter" . "|%%ae|delimiter|%%P|delimiter|%%s|delimiter|%%b|end|\" --name-status"; $logCommand .= " " . $options; if (!empty($gitrevisions)) { $logCommand .= " " . ProcessUtils::escapeshellarg($gitrevisions); } $logCommand = str_replace("|begin|", $commitDelimiter, $logCommand); $logCommand = str_replace("|delimiter|", $dataDelimiter, $logCommand); $logCommand = str_replace("|end|", $statusDelimiter, $logCommand); $log = trim($this->runShellCommandWithStandardOutput($logCommand), $commitDelimiter); if ($log == "") { $commits = []; } else { $commits = explode($commitDelimiter, $log); } return array_map(function ($rawCommitAndStatus) use($statusDelimiter) { list($rawCommit, $rawStatus) = explode($statusDelimiter, $rawCommitAndStatus); return Commit::buildFromString(trim($rawCommit), trim($rawStatus)); }, $commits); }
/** * @param Commit $commit * @param bool $skipVpdbFiles * @return array */ private function getFileChanges(Commit $commit, $skipVpdbFiles) { $changedFiles = $commit->getChangedFiles(); if ($skipVpdbFiles) { $changedFiles = array_filter($changedFiles, function ($changedFile) { $path = str_replace('\\', '/', realpath(VP_PROJECT_ROOT) . '/' . $changedFile['path']); $vpdbPath = str_replace('\\', '/', realpath(VP_VPDB_DIR)); return !Strings::startsWith($path, $vpdbPath); }); } $fileChanges = array_map(function ($changedFile) { $status = $changedFile['status']; $filename = $changedFile['path']; return ['type' => 'file', 'action' => $status === 'A' ? 'add' : ($status === 'M' ? 'modify' : 'delete'), 'name' => $filename]; }, $changedFiles); return $fileChanges; }
/** * @param Commit $commit * @return ChangeInfoEnvelope|UntrackedChangeInfo */ protected function getChangeInfo($commit) { $commitMessageParser = new CommitMessageParser($this->dbSchema, $this->actionsInfoProvider); return $commitMessageParser->parse($commit->getMessage()); }
/** * @param Commit $commit * @return array */ private function getFileChanges(Commit $commit) { $changedFiles = $commit->getChangedFiles(); $changedFiles = array_filter($changedFiles, function ($changedFile) { $path = str_replace('\\', '/', ABSPATH . $changedFile['path']); $vpdbPath = str_replace('\\', '/', VERSIONPRESS_MIRRORING_DIR); return !Strings::startsWith($path, $vpdbPath); }); $fileChanges = array_map(function ($changedFile) { $status = $changedFile['status']; $filename = $changedFile['path']; return array('type' => 'file', 'action' => $status === 'A' ? 'add' : ($status === 'M' ? 'modify' : 'delete'), 'name' => $filename); }, $changedFiles); return $fileChanges; }
private function checkReferencesForRevertedCommit(Commit $revertedCommit) { $changeInfo = ChangeInfoMatcher::buildChangeInfo($revertedCommit->getMessage()); if ($changeInfo instanceof UntrackedChangeInfo) { return true; } foreach ($changeInfo->getChangeInfoList() as $subChangeInfo) { if ($subChangeInfo instanceof EntityChangeInfo && !$this->checkEntityReferences($subChangeInfo->getEntityName(), $subChangeInfo->getEntityId(), $subChangeInfo->getParentId())) { return false; } } return true; }