GitSynchronizer.php
public function synchronize($repository, $token)
    {
        $this->log(LogLevel::INFO, 'Synchronization request for ' . $repository);

        if (false === isset($this['repositories'][$repository])) {
            throw new Exception(400, 'The repository has not been registered', $repository);
        }

        $repo = $this['repositories'][$repository];
        $reqToken = (is_array($repo) && isset($repo['token'])) ? $repo['token'] : $this['token'];
        $directory = (is_array($repo)) ? $repo['path'] : $repo;
        $preSyncCommands = (is_array($repo) && isset($repo['pre-sync-command'])) ? $repo['pre-sync-command'] : array();
        $postSyncCommands = (is_array($repo) && isset($repo['post-sync-command'])) ? $repo['post-sync-command'] : array();

        if (false === is_dir($directory)) {
            throw new Exception(500, 'Configuration error', $repository);
        }

        if ($token !== $reqToken) {
            throw new Exception(401, 'Wrong token, got "' . $token . '"', $repository);
        }

        $this->runCommands($preSyncCommands, $repository);

        $process = new Process("git pull");
        $process->setWorkingDirectory($directory);
        $process->setTimeout(120);
        $process->run();

        $success = false;

        if ($process->isSuccessful()) {
            $this->log(
                LogLevel::NOTICE,
                'Successfully pulled ' . $repository,
                array('output' => $process->getOutput())
            );

            $success = true;
        } else {
            $this->log(
                LogLevel::ERROR,
                'Git pull failed',
                array(
                    'repository' => $repository,
                    'directory' => $directory,
                    'output' => $process->getErrorOutput()
                )
            );
        }

        $this->runCommands($postSyncCommands, $repository);

        return $success;
    }
public function synchronize($repository, $token)
    {
        $this->log(LogLevel::INFO, 'Synchronization request for ' . $repository);

        if (false === isset($this['repositories'][$repository])) {
            throw new Exception(400, 'The repository has not been registered', $repository);
        }

        $repo = $this['repositories'][$repository];
        $reqToken = (is_array($repo) && isset($repo['token'])) ? $repo['token'] : $this['token'];
        $directory = (is_array($repo)) ? $repo['path'] : $repo;
        $preSyncCommands = (is_array($repo) && isset($repo['pre-sync-command'])) ? $repo['pre-sync-command'] : array();
        $postSyncCommands = (is_array($repo) && isset($repo['post-sync-command'])) ? $repo['post-sync-command'] : array();

        if (false === is_dir($directory)) {
            throw new Exception(500, 'Configuration error', $repository);
        }

        if ($token !== $reqToken) {
            throw new Exception(401, 'Wrong token, got "' . $token . '"', $repository);
        }

        $this->runCommands($preSyncCommands, $repository);

        $process = new Process("git pull");
        $process->setWorkingDirectory($directory);
        $process->setTimeout(120);
        $process->run();

        $success = false;

        if ($process->isSuccessful()) {
            $this->log(
                LogLevel::NOTICE,
                'Successfully pulled ' . $repository,
                array('output' => $process->getOutput())
            );

            $success = true;
        } else {
            $this->log(
                LogLevel::ERROR,
                'Git pull failed',
                array(
                    'repository' => $repository,
                    'directory' => $directory,
                    'output' => $process->getErrorOutput()
                )
            );
        }

        $this->runCommands($postSyncCommands, $repository);

        return $success;
    }
Handles a synchronization request

@param string $reposity The URL of the repository to synchronize

@return boolean Returns true on success, false on failure. Please
note that post-sync-commands do not affect the return
value.