show public and private git urls if configured
authorChristian Weiske <cweiske@cweiske.de>
Tue, 3 Apr 2012 20:27:31 +0000 (22:27 +0200)
committerChristian Weiske <cweiske@cweiske.de>
Tue, 3 Apr 2012 20:27:31 +0000 (22:27 +0200)
data/config.php.dist
data/templates/display.htm
src/phorkie/Repository.php
src/phorkie/Repository/Post.php

index b213e85..8ef80e9 100644 (file)
@@ -1,3 +1,5 @@
 <?php
-//$GLOBALS['phorkie']['cfg']['repos'] = '/var/data/phorkie/';
+//$GLOBALS['phorkie']['cfg']['repos'] = '/var/cache/git/paste/';
+//$GLOBALS['phorkie']['cfg']['git']['public'] = 'git://bogo/git/paste/';
+//$GLOBALS['phorkie']['cfg']['git']['private'] = 'ssh://git@bogo:paste/';
 ?>
index f9ab2e5..da75cd9 100644 (file)
  </div>
 </div>
 
+{% if repo.getCloneURL(true) or repo.getCloneURL(false) %}
+<div class="well">
+ {% if repo.getCloneURL(true) %}
+ <div class="row-fluid">
+  <div class="span3">Public clone URL</div>
+  <div class="span9">
+   <a href="{{repo.getCloneURL(true)}}">{{repo.getCloneURL(true)}}</a>
+  </div>
+ </div>
+ {% endif %}
+ {% if repo.getCloneURL(false) %}
+ <div class="row-fluid">
+  <div class="span3">Private clone URL</div>
+  <div class="span9">
+   <a href="{{repo.getCloneURL(false)}}">{{repo.getCloneURL(false)}}</a>
+  </div>
+ </div>
+ {% endif %}
+</div>
+{% endif %}
+
 {% for file in repo.getFiles %}
 <div class="file">
  <div class="header">
index fef5656..6dec015 100644 (file)
@@ -152,6 +152,14 @@ class Repository
         throw new Exception('Unknown link type');
     }
 
+    public function getCloneURL($public = true)
+    {
+        $var = $public ? 'public' : 'private';
+        if (isset($GLOBALS['phorkie']['cfg']['git'][$var])) {
+            return $GLOBALS['phorkie']['cfg']['git'][$var] . $this->id . '/.git';
+        }
+        return null;
+    }
 }
 
 ?>
index 627aa1f..828dbad 100644 (file)
@@ -87,9 +87,13 @@ class Repository_Post
         $repo = $rs->createNew();
         $vc = $repo->getVc();
         $vc->initRepository();
+
         foreach (glob($repo->repoDir . '/.git/hooks/*') as $hookfile) {
             unlink($hookfile);
         }
+
+        touch($repo->repoDir . '/.git/git-daemon-export-ok');
+
         return $repo;
     }