]> jspc29.x-matter.uni-frankfurt.de Git - mvdsensorcontrol.git/commitdiff
added option to change branch during git pull
authorJan Michel <j.michel@gsi.de>
Tue, 30 Jul 2013 16:52:22 +0000 (18:52 +0200)
committerJan Michel <j.michel@gsi.de>
Tue, 30 Jul 2013 16:52:22 +0000 (18:52 +0200)
index.pl
tools/gitupdate.pl

index 7cda9275ca76eade30f3ccdb143accb48b4b4c6c..0a2a0081df209e54c609a73c6ec6f598fd277565 100755 (executable)
--- a/index.pl
+++ b/index.pl
@@ -35,7 +35,7 @@ Guess what? We didn't write any!
 <h3>Update</h3>
 <div class="index">
 <ul>
-<li><a href="tools/gitupdate.pl?stable">Check-out the stable branch without config files</a>
+<li><a href="tools/gitupdate.pl?master">Check-out the stable branch without config files</a>
 <li>Check-out the stable branch including config files: add -config to URL
 </div>
 
index 87ac84a27b64ed94454a8d50354b4e0285dbf47b..1bbf85882ceb661c0e3f84af7984a178aa4a45cc 100755 (executable)
@@ -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");
+  }