Exemplo n.º 1
0
 * along with Tuleap. If not, see <http://www.gnu.org/licenses/>.
 */
require_once 'pre.php';
$git_dao = new GitDao();
$user_manager = UserManager::instance();
$git_repository_factory = new GitRepositoryFactory($git_dao, ProjectManager::instance());
$system_event_manager = new Git_SystemEventManager(SystemEventManager::instance(), $git_repository_factory);
$git_plugin = PluginManager::instance()->getPluginByName('git');
$logger = $git_plugin->getLogger();
if ($argv[1] == "--init") {
    $repository_path = $argv[2];
    $user_name = $argv[3];
    $repository = $git_repository_factory->getFromFullPath($repository_path);
    if ($repository) {
        $system_event_manager->queueGrokMirrorManifestFollowingAGitPush($repository);
    }
} else {
    $repository_path = $argv[1];
    $user_name = $argv[2];
    $old_rev = $argv[3];
    $new_rev = $argv[4];
    $refname = $argv[5];
    try {
        $git_exec = new Git_Exec($repository_path, $repository_path);
        $post_receive = new Git_Hook_PostReceive(new Git_Hook_LogAnalyzer($git_exec, $logger), $git_repository_factory, $user_manager, new Git_Ci_Launcher(new Jenkins_Client(new Http_Client()), new Git_Ci_Dao(), $logger), new Git_Hook_ParseLog(new Git_Hook_LogPushes($git_dao), new Git_Hook_ExtractCrossReferences($git_exec, ReferenceManager::instance()), $logger));
        $post_receive->execute($repository_path, $user_name, $old_rev, $new_rev, $refname);
    } catch (Exception $exception) {
        $logger->error("[git post-receive] {$repository_path} {$user_name} {$refname} {$old_rev} {$new_rev} " . $exception->getMessage());
        exit(1);
    }
}
Exemplo n.º 2
0
$exit_status_code = 0;
$git_dao = new GitDao();
$user_manager = UserManager::instance();
$git_repository_factory = new GitRepositoryFactory($git_dao, ProjectManager::instance());
$system_event_manager = new Git_SystemEventManager(SystemEventManager::instance(), $git_repository_factory);
$git_plugin = PluginManager::instance()->getPluginByName('git');
$logger = $git_plugin->getLogger();
$repository_path = $argv[1];
$git_exec = new Git_Exec($repository_path, $repository_path);
$git_repository_url_manager = new Git_GitRepositoryUrlManager($git_plugin);
$user_name = getenv('GL_USER');
if ($user_name === false) {
    $user_informations = posix_getpwuid(posix_geteuid());
    $user_name = $user_informations['name'];
}
$post_receive = new Git_Hook_PostReceive(new Git_Hook_LogAnalyzer($git_exec, $logger), $git_repository_factory, $user_manager, new Git_Ci_Launcher(new Jenkins_Client(new Http_Client()), new Git_Ci_Dao(), $logger), new Git_Hook_ParseLog(new Git_Hook_LogPushes($git_dao), new Git_Hook_ExtractCrossReferences($git_exec, ReferenceManager::instance()), $logger), $git_repository_url_manager, $system_event_manager);
$mail_builder = new MailBuilder(TemplateRendererFactory::build());
$post_receive->processGrokMirrorActions($repository_path);
$count = 0;
while ($count <= COUNT_THRESHOLD && ($line = fgets(STDIN))) {
    $count += 1;
    list($old_rev, $new_rev, $refname) = explode(' ', trim($line));
    try {
        $post_receive->execute($repository_path, $user_name, $old_rev, $new_rev, $refname, $mail_builder);
    } catch (Exception $exception) {
        $exit_status_code = 1;
        $logger->error("[git post-receive] {$repository_path} {$user_name} {$refname} {$old_rev} {$new_rev} " . $exception->getMessage());
    }
}
if ($count >= COUNT_THRESHOLD) {
    echo "*** info: More than " . COUNT_THRESHOLD . " references in push.\n";