Created
August 18, 2014 21:02
-
-
Save phaus/b9370f7ad3a4ca992425 to your computer and use it in GitHub Desktop.
wp-svn
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/php | |
<?php | |
function getPlugins($url){ | |
$opts = array('http' => | |
array( | |
'method' => 'GET', | |
'header' => "Content-Type: text/html\r\n", | |
'content' => $body, | |
'timeout' => 60 | |
) | |
); | |
$context = stream_context_create($opts); | |
$svn_content = file_get_contents($url, false, $context, -1, 40000); | |
$content = explode ('<li><a href="', $svn_content); | |
$plugins = array(); | |
for($i = 2;$i < count($content);$i++){ | |
$plugins[] = getPlugin($content[$i]); | |
} | |
return $plugins; | |
} | |
function getPlugin($line){ | |
$parts = split('/">', $line); | |
return $parts[0]; | |
} | |
function getVersions($url){ | |
$opts = array('http' => | |
array( | |
'method' => 'GET', | |
'header' => "Content-Type: text/html\r\n", | |
'content' => $body, | |
'timeout' => 60 | |
) | |
); | |
$context = stream_context_create($opts); | |
$svn_content = file_get_contents($url, false, $context, -1, 40000); | |
$content = explode ('<li><a href="', $svn_content); | |
$versions = array(); | |
for($i = 2;$i < count($content);$i++){ | |
$versions[] = getVersion($content[$i]); | |
} | |
return $versions; | |
} | |
function getVersion($line){ | |
$parts = split('/">', $line); | |
return $parts[0]; | |
} | |
function pluginList($input, $index){ | |
global $plugins; | |
return $plugins; | |
} | |
function versionList($input, $index){ | |
global $versions; | |
return $versions; | |
} | |
function checkout($url, $dir){ | |
$svn = `which svn`; | |
$cmd = trim($svn).' co '.$url.' '.$dir; | |
print $cmd."\n"; | |
system($cmd); | |
} | |
$plugin_url = 'http://plugins.svn.wordpress.org/'; | |
$plugins = getPlugins($plugin_url); | |
readline_completion_function('pluginList'); | |
$plugin = readline("install Plugin (TAB to complete): "); | |
$versions = getVersions($plugin_url.trim($plugin).'/tags'); | |
readline_completion_function('versionList'); | |
$version = readline("install Version (TAB to complete): "); | |
print "installing Plugin: {$plugin} in {$version}\n"; | |
$toDir = readline("installing to Directory: "); | |
checkout($plugin_url.trim($plugin).'/tags/'.$version, $toDir); | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/php | |
<?php | |
function getVersions($url){ | |
$opts = array('http' => | |
array( | |
'method' => 'GET', | |
'header' => "Content-Type: text/html\r\n", | |
'content' => $body, | |
'timeout' => 60 | |
) | |
); | |
$context = stream_context_create($opts); | |
$svn_content = file_get_contents($url, false, $context, -1, 40000); | |
$content = explode ('<li><a href="', $svn_content); | |
$versions = array(); | |
for($i = 2;$i < count($content);$i++){ | |
$versions[] = getVersion($content[$i]); | |
} | |
return $versions; | |
} | |
function getVersion($line){ | |
$parts = split('/">', $line); | |
return $parts[0]; | |
} | |
function versionList($input, $index){ | |
global $versions; | |
return $versions; | |
} | |
function checkout($url, $dir){ | |
$svn = `which svn`; | |
$cmd = trim($svn).' co '.$url.' '.$dir; | |
print $cmd."\n"; | |
system($cmd); | |
} | |
$wp_url = 'http://svn.automattic.com/wordpress/tags/'; | |
$versions = getVersions($wp_url); | |
readline_completion_function('versionList'); | |
$version = readline("install Version (TAB to complete): "); | |
print "installing Version: {$version}\n"; | |
$toDir = readline("installing to Directory: "); | |
checkout($wp_url.$version, $toDir); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment