https://www.mediawiki.org/wiki/Special:Code/MediaWiki/114430
Revision: 114430 Author: platonides Date: 2012-03-22 20:34:20 +0000 (Thu, 22 Mar 2012) Log Message: ----------- Script to clone all projects from https://gerrit.wikimedia.org/r/#admin,projects or a subset, excluding part of them. Added Paths: ----------- trunk/tools/code-utils/clone-all.php Added: trunk/tools/code-utils/clone-all.php =================================================================== --- trunk/tools/code-utils/clone-all.php (rev 0) +++ trunk/tools/code-utils/clone-all.php 2012-03-22 20:34:20 UTC (rev 114430) @@ -0,0 +1,55 @@ +#!/usr/bin/env php +<?php +$gerrit = "gerrit.wikimedia.org"; +$baseUrl = "ssh://$gerrit:29418"; // "https://$gerrit/r/p" if you have no ssh access + +$skipRepositories = array( 'test/*', 'operations/*', 'analytics*' ); + + +$command = <<<EOF +wget https://$gerrit/r/gerrit/rpc/ProjectAdminService --post-data='{"jsonrpc":"2.0","method":"visibleProjects","params":[],"id":1}' --header "Content-Type: application/json; charset=utf-8" --header "Accept: application/json" -O - +EOF; + +$totalStart = microtime( true ); +$p = popen( $command, "r" ); +$json = stream_get_contents( $p ); +pclose( $p ); + +$rpc = json_decode( $json ); +$projects = $rpc->result; + +//print_r( $projects ); + +foreach ( $projects as $project ) { + $repo = $project->name->name; + print "$repo\n"; + + if ( strpos( $project->description, "DON'T USE" ) !== false ) { + echo " Don't use, skipped\n"; + continue; + } + + foreach ( $skipRepositories as $skip ) { + if ( fnmatch( $skip, $repo, FNM_CASEFOLD ) ) { + echo " Skipped\n"; + continue 2; + } + } + + if ( file_exists( "$repo/.git" ) ) { + echo " There's already a repository at $repo\n"; + continue; + } + + $start = microtime( true ); + passthru( "git clone " . escapeshellarg( "$baseUrl/$repo.git" ) . " " . escapeshellarg( $repo ), $exitCode ); + $end = microtime( true ); + echo " $repo cloned in ", $end - $start, " seconds.\n"; + if ( $exitCode ) { + echo " $repo clone failed.\n"; + exit( $exitCode ); + } +} +$totalEnd = microtime( true ); + +echo "Total time: ", $totalEnd - $totalStart, " seconds\n"; Property changes on: trunk/tools/code-utils/clone-all.php ___________________________________________________________________ Added: svn:executable + * Added: svn:eol-style + native _______________________________________________ MediaWiki-CVS mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs
