Merge "Change CdbException to subclass Exception"
[lhc/web/wiklou.git] / includes / GitInfo.php
index a54b807..e0bd5cd 100644 (file)
@@ -143,8 +143,7 @@ class GitInfo {
                } else {
                        return (int)$commitDate;
                }
-
-        }
+       }
 
        /**
         * Return the name of the current branch, or HEAD if not found
@@ -162,7 +161,7 @@ class GitInfo {
        /**
         * Get an URL to a web viewer link to the HEAD revision.
         *
-        * @return string|bool string if an URL is available or false otherwise.
+        * @return string|bool string if a URL is available or false otherwise.
         */
        public function getHeadViewUrl() {
                $config = "{$this->basedir}/config";
@@ -194,12 +193,13 @@ class GitInfo {
                }
                foreach ( self::getViewers() as $repo => $viewer ) {
                        $pattern = '#^' . $repo . '$#';
-                       if ( preg_match( $pattern, $url ) ) {
+                       if ( preg_match( $pattern, $url, $matches ) ) {
                                $viewerUrl = preg_replace( $pattern, $viewer, $url );
                                $headSHA1 = $this->getHeadSHA1();
                                $replacements = array(
                                        '%h' => substr( $headSHA1, 0, 7 ),
-                                       '%H' => $headSHA1
+                                       '%H' => $headSHA1,
+                                       '%r' => urlencode( $matches[1] ),
                                );
                                return strtr( $viewerUrl, $replacements );
                        }