From: Jan Michel Date: Tue, 30 Jul 2013 16:52:22 +0000 (+0200) Subject: added option to change branch during git pull X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=83e1aca7e875c523a4a84b30e868d90b15a8a8d0;p=mvdsensorcontrol.git added option to change branch during git pull --- diff --git a/index.pl b/index.pl index 7cda927..0a2a008 100755 --- a/index.pl +++ b/index.pl @@ -35,7 +35,7 @@ Guess what? We didn't write any!

Update

diff --git a/tools/gitupdate.pl b/tools/gitupdate.pl index 87ac84a..1bbf858 100755 --- a/tools/gitupdate.pl +++ b/tools/gitupdate.pl @@ -9,28 +9,28 @@ use CGI::Carp qw(fatalsToBrowser); my $query = $ENV{'QUERY_STRING'}; sub cmd { - my ($c) = @_; - $c .= " 2>&1"; - my @x = qx($c); - foreach (@x) { - print "> ".$_; - } + my ($c) = @_; + $c .= " 2>&1"; + my @x = qx($c); + foreach (@x) { + print "> ".$_; + } } +my @commands = split("-",$query); +unless(defined $commands[0]) { + print "No valid operation given.\n"; + exit; + } print "Running Git Update\n"; -unless ($query =~ m/stable/) { - print "Function not implemented.\n"; - exit; - } - -unless ($query =~ m/config/) { - print "Copying configuration file folder\n"; - cmd("cp -r ../config ../temp/config"); - } +unless (defined $commands[1] && $commands[1] eq "config") { + print "Copying configuration file folder\n"; + cmd("cp -r ../config ../temp/config"); + } print "Undoing changes in config files\n"; @@ -39,13 +39,17 @@ cmd("git checkout -- ../config ../temp"); print "Pulling new data from server\n"; cmd("git pull "); -unless ($query =~ m/config/) { - print "Copying configuration file folder back\n"; - cmd("cp -r ../temp/config ../"); +print "Changing to branch $commands[0].\n"; +cmd("git checkout $commands[0]"); + + +unless (defined $commands[1] && $commands[1] eq "config") { + print "Copying configuration file folder back\n"; + cmd("cp -r ../temp/config ../"); - print "Removing temporary configuration file folder\n"; - cmd("rm -r ../temp/config"); - } + print "Removing temporary configuration file folder\n"; + cmd("rm -r ../temp/config"); + }