/**
* Run the action
* @param Commit $commit commit to verify
* @throws GitHookException if requirement fails
*/
public function run(Commit $commit)
{
$frozenRepos = $this->config->frozenRepoNames();
if (count($frozenRepos) == 0) {
$this->logger->debug("No frozen repos.");
return;
}
// Super users are exempt from frozen checks
// So hope they don't do anything bad by mistake!
if ($this->isSuperUser()) {
$this->logger->debug("Superuser exempt from freeze");
return;
}
if ($frozenRepos === ['all']) {
throw new GitHookException('All repositories are frozen.');
}
$project = $commit->getProjectName();
$this->logger->debug("Validating if {$project} is frozen");
if (in_array($project, $frozenRepos)) {
throw new GitHookException("{$project} repository is frozen.");
}
}