public function execute($repository_path, $user_name, $oldrev, $newrev, $refname) { $repository = $this->repository_factory->getFromFullPath($repository_path); if ($repository !== null) { $user = $this->user_manager->getUserByUserName($user_name); if ($user === null) { $user = new PFUser(array('user_id' => 0)); } $this->executeForRepositoryAndUser($repository, $user, $oldrev, $newrev, $refname); } }
/** * Store details about the push in the DB * * @param String $repositoryLocation Name of the git repository * @param String $identifier Name of the gitshell user that performed the push, retrived from whoami output. * @param Integer $pushTimestamp Date of the commit * @param Integer $commitsNumber Number of commits * @param String $gitoliteUser Name of the gitolite user that performed the push, retrived from environment var $GL_USER. * * @return void */ function logGitPushes($repositoryLocation, $identifier, $pushTimestamp, $commitsNumber, $gitoliteUser) { $repoFactory = new GitRepositoryFactory(new GitDao(), ProjectManager::instance()); $repository = $repoFactory->getFromFullPath($repositoryLocation); if ($repository) { $repository->logGitPush($identifier, $pushTimestamp, $commitsNumber, $gitoliteUser); } }
/** * Trigger jobs corresponding to the Git repository * * @param String $repositoryLocation Name of the git repository * * @return Void */ function triggerCiBuild($repositoryLocation) { $pm = ProjectManager::instance(); $repoFactory = new GitRepositoryFactory(new GitDao(), $pm); $repository = $repoFactory->getFromFullPath($repositoryLocation); if ($repository) { if ($repository->getProject()->usesService('hudson')) { $gitCi = new Git_CI(); $gitCi->triggerCiBuild($repository->getId()); } } }
function testGetRepositoryFromFullPathAndGitRoot() { $dao = new MockGitDao(); $projectManager = new MockProjectManager(); $project = new MockProject(); $project->setReturnValue('getID', 101); $project->setReturnValue('getUnixName', 'garden'); $projectManager->setReturnValue('getProjectByUnixName', $project, array('garden')); $factory = new GitRepositoryFactory($dao, $projectManager); $dao->expectOnce('searchProjectRepositoryByPath', array(101, 'garden/diskinstaller.git')); $dao->setReturnValue('searchProjectRepositoryByPath', new MockDataAccessResult()); $factory->getFromFullPath('/data/tuleap/gitroot/garden/diskinstaller.git'); }
* GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * 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());