Git Repositories

HTTP git access and nginx configuration in installation comment.
authorCyrille Pontvieux <jrd@enialis.net>
Thu, 6 Nov 2014 15:52:48 +0000 (15:52 +0000)
committerCyrille Pontvieux <jrd@enialis.net>
Thu, 6 Nov 2014 15:52:48 +0000 (15:52 +0000)
homegit/gitrepo.sh
install.sh
src/repo-info.php
src/repo-list.php
src/style.css

index 1134025..1f41ddb 100755 (executable)
@@ -324,8 +324,18 @@ exportRepo() {
   check_repo "$NAME"
   if [ "$DOEXPORT" = "on" ]; then
     touch "$NAME".git/git-daemon-export-ok
+    (
+      cd "$NAME".git
+      git config http.getanyfile false
+      git config http.uploadpack true
+      git config http.receivepack false
+    )
   else
     rm -f "$NAME".git/git-daemon-export-ok
+    (
+      cd "$NAME".git
+      git config --unset-all http
+    )
   fi
 }
 
index 414975e..625610f 100755 (executable)
@@ -126,6 +126,47 @@ Here is the configuration to add to your virtual host apache file:
     AddHandler cgi-script cgi
     DirectoryIndex gitweb.cgi
   </Directory>
+For nginx, here is one configuration snippet:
+  server {
+    listen       localhost:80;
+    server_name  $GIT_HOST;
+    root   /var/www/$GIT_WEB_PATH;
+    index  controller.php;
+    access_log  /var/www/$GIT_WEB_PATH/../logs/access.log combined;
+    error_log /var/www/$GIT_WEB_PATH/../logs/error.log;
+    location / {
+      try_files \$uri \$uri/ /controller.php?\$args;
+    }
+    location ~ \.php$ {
+      # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9001
+      fastcgi_pass   unix:/var/run/php-fpm.sock;
+      include        fastcgi_params;
+      fastcgi_param  SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
+    }
+    location /gitweb/ {
+      gzip off;
+      index          gitweb.cgi;
+      include        fastcgi_params;
+      fastcgi_param  SCRIPT_NAME gitweb.cgi; 
+      fastcgi_param  SCRIPT_FILENAME /var/www/$GIT_WEB_PATH/gitweb/gitweb.cgi;
+      fastcgi_param  GITWEB_CONFIG /etc/gitweb.conf;
+      if (\$uri ~ "/gitweb/gitweb.cgi") {
+        fastcgi_pass   unix:/var/run/fcgiwrap.sock;
+      }
+    }
+    location ~ /git(/.*) {
+      gzip off;
+      # Set chunks to unlimited, as the body's can be huge
+      client_max_body_size 0;
+      fastcgi_pass unix:/var/run/fcgiwrap.sock;
+      include fastcgi_params;
+      fastcgi_param SCRIPT_FILENAME /usr/libexec/git-core/git-http-backend;
+      fastcgi_param GIT_HTTP_EXPORT_ALL "";
+      fastcgi_param GIT_PROJECT_ROOT $GIT_DIR;
+      fastcgi_param PATH_INFO \$1;
+    }
+  }
 
 Have fun ;-)
 EOF
index 7f42747..82993ed 100644 (file)
@@ -81,7 +81,9 @@ exec("GIT_DIR=$gitdir/$repo.git git ls-tree -r --name-only -z refs/heads/$select
           <h2>URL</h2>
           <div class="rw"><?php echo "$gituser@$githost:$repo.git"; ?></div>
           <?php if (file_exists("$gitdir/$repo.git/git-daemon-export-ok")) { ?>
-            <div class="ro"><?php echo "git://$githost/$repo.git"; ?></div>
+            <div class="ro-git"><?php echo "git://$githost/$repo.git"; ?></div>
+            <?php $httpurl = sprintf('%s://%s/git/%s.git', isset($_SERVER['HTTPS']) ? 'https' : 'http', $_SERVER['HTTP_HOST'], $repo); ?>
+            <div class="ro-http"><?php echo "$httpurl"; ?></div>
           <?php } ?>
         </div>
       </div>
index 5d5d08d..a36b53d 100644 (file)
@@ -58,7 +58,9 @@ foreach ($files as $file) {
     echo "        <tr><td class=\"name\" title=\"$desc\">$name</td><td class=\"address\">";
     echo "<div class=\"rw\">$gituser@$githost:$file</div>";
     if ($exportok) {
-      echo "<div class=\"ro\">git://$githost/$file</div>";
+      echo "<div class=\"ro-git\">git://$githost/$file</div>";
+      $httpurl = sprintf('%s://%s/git/%s', isset($_SERVER['HTTPS']) ? 'https' : 'http', $_SERVER['HTTP_HOST'], $file);
+      echo "<div class=\"ro-http\">$httpurl</div>";
     }
     echo "</td><td class=\"member\">$membre</td><td class=\"actions\">$actions</td></tr>\n";
   }
index fd72bcf..0ea2cf8 100644 (file)
@@ -95,13 +95,24 @@ div.rw {
   color: black;
   font-weight: bold;
 }
-div.ro {
-  color: gray;
+div.rw:after {
+  content: " (rw)";
   font-style: italic;
+  color: gray;
+}
+div.ro-git,
+div.ro-http {
+  color: maroon;
   padding-left: 20px;
 }
-div.ro:after {
+div.ro-http {
+  margin-bottom: 5px;
+}
+div.ro-git:after,
+div.ro-http:after {
   content: " (readonly)";
+  font-style: italic;
+  color: gray;
 }
 #new-desc {
   min-width: 400px;