aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Fischer <bantu@phpbb.com>2011-01-25 18:41:59 +0100
committerAndreas Fischer <bantu@phpbb.com>2011-02-03 11:12:48 +0100
commit8eee36dc0f6111c3a4a6a50d0e33833f19430a0e (patch)
treed2b8c299c41e0f2819c35d5e4c4c1caf528cc608
parent57bd0c74e50e2171653d45d9723f2417411c71f4 (diff)
downloadforums-8eee36dc0f6111c3a4a6a50d0e33833f19430a0e.tar
forums-8eee36dc0f6111c3a4a6a50d0e33833f19430a0e.tar.gz
forums-8eee36dc0f6111c3a4a6a50d0e33833f19430a0e.tar.bz2
forums-8eee36dc0f6111c3a4a6a50d0e33833f19430a0e.tar.xz
forums-8eee36dc0f6111c3a4a6a50d0e33833f19430a0e.zip
[ticket/9805] Add dry-run option.
PHPBB3-9805
-rw-r--r--git-tools/setup_github_network.php22
1 files changed, 19 insertions, 3 deletions
diff --git a/git-tools/setup_github_network.php b/git-tools/setup_github_network.php
index 66d7db87da..04187aaa4a 100644
--- a/git-tools/setup_github_network.php
+++ b/git-tools/setup_github_network.php
@@ -40,16 +40,19 @@ function show_usage()
echo " -u github_username Overwrites the github username (optional)\n";
echo " -r repository_name Overwrites the repository name (optional)\n";
echo " -m your_github_username Sets up ssh:// instead of git:// for pushable repositories (optional)\n";
+ echo " -d Outputs the commands instead of running them (optional)\n";
exit(1);
}
// Handle arguments
-$opts = getopt('s:u:r:m:');
+$opts = getopt('s:u:r:m:d');
$scope = get_arg($opts, 's', '');
$username = get_arg($opts, 'u', 'phpbb');
$repository = get_arg($opts, 'r', 'phpbb3');
$developer = get_arg($opts, 'm', '');
+$dry_run = !get_arg($opts, 'd', true);
+run(null, $dry_run);
// Get some basic data
$network = get_network($username, $repository);
@@ -189,7 +192,20 @@ function get_arg($array, $index, $default)
return isset($array[$index]) ? $array[$index] : $default;
}
-function run($cmd)
+function run($cmd, $dry = false)
{
- passthru(escapeshellcmd($cmd));
+ static $dry_run;
+
+ if (is_null($cmd))
+ {
+ $dry_run = $dry;
+ }
+ else if (!empty($dry_run))
+ {
+ echo "$cmd\n";
+ }
+ else
+ {
+ passthru(escapeshellcmd($cmd));
+ }
}