create a new snapshot function
authorStricted <Stricted@nexus-irc.de>
Sat, 8 Sep 2012 16:21:18 +0000 (18:21 +0200)
committerStricted <Stricted@nexus-irc.de>
Sun, 9 Sep 2012 12:29:20 +0000 (14:29 +0200)
git_download.php
index.cgi

index 7d360931d93d18fbf9d0f57ab0fc1364a35efad1..d4c3c4ebce627dc2e1f9c9e38b9bdf2c3e3711ce 100644 (file)
@@ -1,4 +1,9 @@
 <?php
+$args = explode(";", $_SERVER["QUERY_STRING"]);
+foreach($args as $arg) {
+    $arg = explode("=", $arg, 2);
+    $_GET[$arg[0]] = $arg[1];
+}
 if(isset($_GET['p'])){
        if(file_exists("/home/git/".$_GET['p'])){
                $hash = shell_exec("git --git-dir=/home/git/".$_GET["p"]." rev-list -n 1 --pretty='format:%h' --header master | grep '^[0-9a-f]*$'");
@@ -7,8 +12,8 @@ if(isset($_GET['p'])){
                        echo "No Download available";
                }else{
                        $name=substr($_GET["p"],0,strlen($_GET["p"])-4);  
-                       if(file_exists("/usr/share/gitweb/dl/".$name."-git-".substr($con, 0, -1)."-".substr($hash, 0, -1).".tar.gz")) {
-                               echo "<a href='http://git.nexus-irc.de/dl/".$name."-git-".substr($con, 0, -1)."-".substr($hash, 0, -1).".tar.gz'>git-".substr($con, 0, -1)."-".substr($hash, 0, -1)." (tar.gz)</a>";
+                       if(file_exists("/usr/share/gitweb/dl/".$name."-".substr($hash, 0, -1).".tar.gz")) {
+                               echo "<a href='http://git.nexus-irc.de/dl/".$name."-".substr($hash, 0, -1).".tar.gz'>".$name."-".substr($hash, 0, -1)." (tar.gz)</a>";
                        } else {
                                echo "No Download available (<a href='http://git.nexus-irc.de/git_download.php?build2=".$_GET["p"]."'>Build snapshot</a>)";
                        }
@@ -24,8 +29,8 @@ if(isset($_GET['p'])){
                        echo "<p>".$_GET["git"].": No Download available</p>";
                }else{
                        $name=substr($_GET["git"],0,strlen($_GET["git"])-4);  
-                       if(file_exists("/usr/share/gitweb/dl/".$name."-git-".substr($con, 0, -1)."-".substr($hash, 0, -1).".tar.gz")) {
-                               echo "<p><a href='http://git.nexus-irc.de/dl/".$name."-git-".substr($con, 0, -1)."-".substr($hash, 0, -1).".tar.gz'>git-".substr($con, 0, -1)."-".substr($hash, 0, -1)." (tar.gz)</a></p>";
+                       if(file_exists("/usr/share/gitweb/dl/".$name."-".substr($hash, 0, -1).".tar.gz")) {
+                               echo "<p><a href='http://git.nexus-irc.de/dl/".$name."-".substr($hash, 0, -1).".tar.gz'>".$name."-".substr($hash, 0, -1)." (tar.gz)</a></p>";
                        } else {
                                echo "<p>No Download available (<a href='http://git.nexus-irc.de/git_download.php?build3=".$_GET["git"]."'>Build snapshot</a>)</p>";
                        }
@@ -35,14 +40,14 @@ if(isset($_GET['p'])){
        }
 }elseif(isset($_GET['build'])){
        if(file_exists("/home/git/".$_GET['build'])){
+               $hash = shell_exec("git --git-dir=/home/git/".$_GET['build']." rev-list -n 1 --pretty='format:%h' --header master | grep '^[0-9a-f]*$'");
+               $con= shell_exec('git --git-dir=/home/git/'.$_GET['build'].' rev-list --oneline --header master | wc -l | sed "s/[ \t]//g"');
                $name=substr($_GET['build'],0,strlen($_GET['build'])-4);
-               if(file_exists("/usr/share/gitweb/dl/".$name."-git-".substr($con, 0, -1)."-".substr($hash, 0, -1).".tar.gz")) {
+               if(file_exists("/usr/share/gitweb/dl/".$name."-".substr($hash, 0, -1).".tar.gz")) {
                        echo '<meta http-equiv="refresh" content="0; URL=http://git.nexus-irc.de/?a=download"> ';
                }else{
-                       $hash = shell_exec("git --git-dir=/home/git/".$_GET['build']." rev-list -n 1 --pretty='format:%h' --header master | grep '^[0-9a-f]*$'");
-                       $con= shell_exec('git --git-dir=/home/git/'.$_GET['build'].' rev-list --oneline --header master | wc -l | sed "s/[ \t]//g"');
                        $b = shell_exec("cd /usr/share/gitweb/dl; git clone git://git.nexus-irc.de/".$_GET['build']);
-                       $c = shell_exec("cd /usr/share/gitweb/dl; tar czfv ".$name."-git-".substr($con, 0, -1)."-".substr($hash, 0, -1).".tar.gz ".$name);
+                       $c = shell_exec("cd /usr/share/gitweb/dl; tar czfv ".$name."-".substr($hash, 0, -1).".tar.gz ".$name);
                        $d = shell_exec("rm -r /usr/share/gitweb/dl/".$name);
                        echo '<meta http-equiv="refresh" content="0; URL=http://git.nexus-irc.de/?a=download"> ';
                }
@@ -51,32 +56,54 @@ if(isset($_GET['p'])){
        }
 }elseif(isset($_GET['build2'])){
        if(file_exists("/home/git/".$_GET['build2'])){
+               $hash = shell_exec("git --git-dir=/home/git/".$_GET['build2']." rev-list -n 1 --pretty='format:%h' --header master | grep '^[0-9a-f]*$'");
+               $con= shell_exec('git --git-dir=/home/git/'.$_GET['build2'].' rev-list --oneline --header master | wc -l | sed "s/[ \t]//g"');
                $name=substr($_GET['build2'],0,strlen($_GET['build2'])-4);
-               if(file_exists("/usr/share/gitweb/dl/".$name."-git-".substr($con, 0, -1)."-".substr($hash, 0, -1).".tar.gz")) {
+               if(file_exists("/usr/share/gitweb/dl/".$name."-".substr($hash, 0, -1).".tar.gz")) {
                        echo '<meta http-equiv="refresh" content="0; URL=http://git.nexus-irc.de/?p='.$_GET['build2'].';a=summary"> ';
                }else{
-               $hash = shell_exec("git --git-dir=/home/git/".$_GET['build2']." rev-list -n 1 --pretty='format:%h' --header master | grep '^[0-9a-f]*$'");
-               $con= shell_exec('git --git-dir=/home/git/'.$_GET['build2'].' rev-list --oneline --header master | wc -l | sed "s/[ \t]//g"');
-               $b = shell_exec("cd /usr/share/gitweb/dl/; git clone git://git.nexus-irc.de/".$_GET['build2']);
-               $c = shell_exec("cd /usr/share/gitweb/dl; tar czfv ".$name."-git-".substr($con, 0, -1)."-".substr($hash, 0, -1).".tar.gz ".$name);
-               $d = shell_exec("rm -r /usr/share/gitweb/dl/".$name);
-               echo '<meta http-equiv="refresh" content="0; URL=http://git.nexus-irc.de/?p='.$_GET['build2'].';a=summary"> ';
+                       $b = shell_exec("cd /usr/share/gitweb/dl/; git clone git://git.nexus-irc.de/".$_GET['build2']);
+                       $c = shell_exec("cd /usr/share/gitweb/dl; tar czfv ".$name."-".substr($hash, 0, -1).".tar.gz ".$name);
+                       $d = shell_exec("rm -r /usr/share/gitweb/dl/".$name);
+                       echo '<meta http-equiv="refresh" content="0; URL=http://git.nexus-irc.de/?p='.$_GET['build2'].';a=summary"> ';
                }
        }else{
                echo "unknown project";
        }
 }elseif(isset($_GET['build3'])){
        if(file_exists("/home/git/".$_GET['build3'])){
+               $hash = shell_exec("git --git-dir=/home/git/".$_GET['build3']." rev-list -n 1 --pretty='format:%h' --header master | grep '^[0-9a-f]*$'");
+               $con= shell_exec('git --git-dir=/home/git/'.$_GET['build3'].' rev-list --oneline --header master | wc -l | sed "s/[ \t]//g"');
                $name=substr($_GET['build3'],0,strlen($_GET['build3'])-4);
-               if(file_exists("/usr/share/gitweb/dl/".$name."-git-".substr($con, 0, -1)."-".substr($hash, 0, -1).".tar.gz")) {
+               if(file_exists("/usr/share/gitweb/dl/".$name."-".substr($hash, 0, -1).".tar.gz")) {
                        echo '<meta http-equiv="refresh" content="0; URL=http://stats.nexus-irc.de/"> ';
                }else{
-               $hash = shell_exec("git --git-dir=/home/git/".$_GET['build3']." rev-list -n 1 --pretty='format:%h' --header master | grep '^[0-9a-f]*$'");
-               $con= shell_exec('git --git-dir=/home/git/'.$_GET['build3'].' rev-list --oneline --header master | wc -l | sed "s/[ \t]//g"');
-               $b = shell_exec("cd /usr/share/gitweb/dl/; git clone git://git.nexus-irc.de/".$_GET['build3']);
-               $c = shell_exec("cd /usr/share/gitweb/dl; tar czfv ".$name."-git-".substr($con, 0, -1)."-".substr($hash, 0, -1).".tar.gz ".$name);
-               $d = shell_exec("rm -r /usr/share/gitweb/dl/".$name);
-               echo '<meta http-equiv="refresh" content="0; URL=http://stats.nexus-irc.de/"> ';
+                       $b = shell_exec("cd /usr/share/gitweb/dl/; git clone git://git.nexus-irc.de/".$_GET['build3']);
+                       $c = shell_exec("cd /usr/share/gitweb/dl; tar czfv ".$name."-".substr($hash, 0, -1).".tar.gz ".$name);
+                       $d = shell_exec("rm -r /usr/share/gitweb/dl/".$name);
+                       echo '<meta http-equiv="refresh" content="0; URL=http://stats.nexus-irc.de/"> ';
+               }
+       }else{
+               echo "unknown project";
+       }
+}elseif(isset($_GET['build4']) && isset($_GET['h'])){
+       if(file_exists("/home/git/".$_GET['build4'])){
+               $name=substr($_GET['build4'],0,strlen($_GET['build4'])-4);
+               if(strtolower($_GET['h']) == "head") {
+                       $hash = shell_exec("git --git-dir=/home/git/".$_GET['p']." rev-list -n 1 --pretty='format:%h' --header master | grep '^[0-9a-f]*$'");
+               }else{
+                       $hash = substr($_GET['h'], 0, 7);
+               }
+               if(file_exists("/usr/share/gitweb/dl/".$name."-".$hash.".tar.gz")) {
+                       echo '<meta http-equiv="refresh" content="0; URL=http://git.nexus-irc.de/dl/'.$name.'-'.$hash.'.tar.gz">';
+                       echo '<a href="javascript:history.go(-1)">zurück</a>';
+               }else{
+                       $b = shell_exec("cd /usr/share/gitweb/dl/; git clone git://git.nexus-irc.de/".$_GET['build4']);
+                       $c = shell_exec("cd /usr/share/gitweb/dl/".$name."/; git reset ".$_GET['h']);
+                       $c = shell_exec("cd /usr/share/gitweb/dl; tar czfv ".$name."-".$hash.".tar.gz ".$name);
+                       $d = shell_exec("rm -r /usr/share/gitweb/dl/".$name);
+                       echo '<meta http-equiv="refresh" content="0; URL=http://git.nexus-irc.de/dl/'.$name.'-'.$hash.'.tar.gz">';
+                       echo '<a href="javascript:history.go(-1)">zurück</a>';
                }
        }else{
                echo "unknown project";
@@ -92,8 +119,8 @@ if(isset($_GET['p'])){
                                echo "<p>".$v.": No Download available</p>";
                        }else{
                                $name=substr($v,0,strlen($v)-4);
-                               if(file_exists("/usr/share/gitweb/dl/".$name."-git-".substr($con, 0, -1)."-".substr($hash, 0, -1).".tar.gz")) {
-                                       echo "<p>".$v.": Download <a href='http://git.nexus-irc.de/dl/".$name."-git-".substr($con, 0, -1)."-".substr($hash, 0, -1).".tar.gz'>git-".substr($con, 0, -1)."-".substr($hash, 0, -1)."</a></p>";
+                               if(file_exists("/usr/share/gitweb/dl/".$name."-".substr($hash, 0, -1).".tar.gz")) {
+                                       echo "<p>".$v.": Download <a href='http://git.nexus-irc.de/dl/".$name."-".substr($hash, 0, -1).".tar.gz'>".$name."-".substr($hash, 0, -1)." (tar.gz)</a></p>";
                                } else {
                                        echo "<p>".$v.": No Download available (<a href='http://git.nexus-irc.de/git_download.php?build=".$v."'>Build snapshot</a>)</p>";       
                                }
index fe7ff60b710ea349d34d6742da51f4ad1cfcc183..f301fbd842f60283d6af182566081390647ca0b9 100644 (file)
--- a/index.cgi
+++ b/index.cgi
@@ -4829,11 +4829,9 @@ sub git_shortlog_body {
                      "<td class=\"link\">" .
                      $cgi->a({-href => href(action=>"commit", hash=>$commit)}, "commit") . " | " .
                      $cgi->a({-href => href(action=>"commitdiff", hash=>$commit)}, "commitdiff") . " | " .
-                     $cgi->a({-href => href(action=>"tree", hash=>$commit, hash_base=>$commit)}, "tree");
-               my $snapshot_links = format_snapshot_links($commit);
-               if (defined $snapshot_links) {
-                       print " | " . $snapshot_links;
-               }
+                     $cgi->a({-href => href(action=>"tree", hash=>$commit, hash_base=>$commit)}, "tree"). " | " .
+                     "<a title='in format: tar.gz' href='http://git.nexus-irc.de/git_download.php?build4=".$project.";h=".$commit."'>snapshot</a>";
+
                print "</td>\n" .
                      "</tr>\n";
        }
@@ -5793,10 +5791,10 @@ sub git_tree {
                                                       hash_base=>"HEAD", file_name=>$file_name)},
                                        "HEAD"),
                }
-               my $snapshot_links = format_snapshot_links($hash);
+               my $snapshot_links = "1";
                if (defined $snapshot_links) {
                        # FIXME: Should be available when we have no hash base as well.
-                       push @views_nav, $snapshot_links;
+                       push @views_nav, "<a title='in format: tar.gz' href='http://git.nexus-irc.de/git_download.php?build4=".$project.";h=".$hash."'>snapshot</a>";
                }
                git_print_page_nav('tree','', $hash_base, undef, undef,
                                   join(' | ', @views_nav));
@@ -6112,9 +6110,9 @@ sub git_commit {
              "<td class=\"link\">" .
              $cgi->a({-href => href(action=>"tree", hash=>$co{'tree'}, hash_base=>$hash)},
                      "tree");
-       my $snapshot_links = format_snapshot_links($hash);
+       my $snapshot_links = "1";
        if (defined $snapshot_links) {
-               print " | " . $snapshot_links;
+               print " | " . "<a title='in format: tar.gz' href='http://git.nexus-irc.de/git_download.php?build4=".$project.";h=".$hash."'>snapshot</a>";
        }
        print "</td>" .
              "</tr>\n";