Bart\GitHook\GitHookController::processRevisions PHP Method

processRevisions() private method

Run each revision against current hook
private processRevisions ( )
    private function processRevisions()
    {
        /** @var \Bart\Git $git */
        $git = Diesel::create('\\Bart\\Git', $this->gitDir);
        /** @var \Bart\Shell $shell */
        $shell = Diesel::create('\\Bart\\Shell');
        // TODO This will need to change to support the 'update' hook
        $stdin = $shell->std_in();
        foreach ($stdin as $rangeAndRef) {
            list($startHash, $endHash, $ref) = explode(" ", $rangeAndRef);
            $endCommit = Diesel::create('\\Bart\\Git\\Commit', $this->gitRoot, $endHash);
            /** @var \Bart\GitHook\GitHookConfig $configs */
            $configs = Diesel::create('\\Bart\\GitHook\\GitHookConfig', $endCommit);
            $validRefs = $configs->getValidRefs();
            // Check whether current ref should have git hooks run or not
            if (!in_array($ref, $validRefs)) {
                $this->logger->info("Skipping hooks for {$ref}; valid refs are " . implode(', ', $validRefs));
                continue;
            }
            // TODO should this be reversed?
            // TODO This list could be massive for branches, should we have some config for how deep to go?
            $revisions = $git->getRevList($startHash, $endHash);
            $this->logger->debug('Found ' . count($revisions) . ' revision(s)');
            foreach ($revisions as $revision) {
                $commit = Diesel::create('\\Bart\\Git\\Commit', $this->gitRoot, $revision, $this->projectName);
                // Allow a backdoor in case of emergency or broken hook configuration
                if ($this->shouldSkip($commit, $configs)) {
                    continue;
                }
                $hookRunner = $this->createHookRunner($commit);
                $this->logger->debug("Created {$hookRunner}");
                $this->logger->debug("Verifying all configured hook actions against {$revision}");
                // Let any failures bubble up to caller
                $hookRunner->runAllActions();
            }
        }
    }