From dfb4dcaa3204b5570dfbf2fbfe96cc529d80a447 Mon Sep 17 00:00:00 2001 From: Erik Fonnesbeck Date: Tue, 28 Feb 2012 12:14:21 -0700 Subject: Allow specifying the branch name after the repository URL for gitsync command-line arguments and remove an unnecessary use of the backtick operator. --- etc/phpshellsessions/gitsync | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) (limited to 'etc/phpshellsessions') diff --git a/etc/phpshellsessions/gitsync b/etc/phpshellsessions/gitsync index 0689f7c..9550d5d 100644 --- a/etc/phpshellsessions/gitsync +++ b/etc/phpshellsessions/gitsync @@ -112,18 +112,30 @@ foreach($branches as $branchname => $branchdesc) { } if(!$found) { if(isURL($branch) && !$upgrading) { - echo "\n"; - echo "NOTE: $branch was not found.\n\n"; - $command = readline("Is this a custom GIT URL? [y]? "); - if(strtolower($command) == "y" or $command == "") { + if($command_split[3]) { + $GIT_REPO = $branch; + $branch = $command_split[3]; + $found = true; + } + else if($argv[4]) { $GIT_REPO = $branch; - $command = readline("Checkout which branch [RELENG_2_0]? "); - if($command == "") - $branch = "RELENG_2_0"; - if($command) - $branch = $command; + $branch = $argv[4]; $found = true; } + else { + echo "\n"; + echo "NOTE: $branch was not found.\n\n"; + $command = readline("Is this a custom GIT URL? [y]? "); + if(strtolower($command) == "y" or $command == "") { + $GIT_REPO = $branch; + $command = readline("Checkout which branch [RELENG_2_0]? "); + if($command == "") + $branch = "RELENG_2_0"; + if($command) + $branch = $command; + $found = true; + } + } } if(!$found) { echo "\nNo valid branch found. Exiting.\n\n"; @@ -200,7 +212,7 @@ if($branch == "build_commit") { $git_cmd = array( "cd $CODIR/pfSenseGITREPO/pfSenseGITREPO && git branch " . escapeshellarg($branch) . " 2>/dev/null", "cd $CODIR/pfSenseGITREPO/pfSenseGITREPO && git checkout -f " . escapeshellarg($branch) . " 2>/dev/null", - "cd $CODIR/pfSenseGITREPO/pfSenseGITREPO && git reset --hard `cat /etc/version.lastcommit`" + "cd $CODIR/pfSenseGITREPO/pfSenseGITREPO && git reset --hard " . escapeshellarg(file_get_contents("/etc/version.lastcommit")) ); } else { $git_cmd = array( -- cgit v1.1