$wgGitRepositoryViewers to link to gitweb
authorsaper <saper@saper.info>
Sun, 6 May 2012 20:12:14 +0000 (22:12 +0200)
committersaper <saper@saper.info>
Sun, 6 May 2012 20:12:14 +0000 (22:12 +0200)
My git remote is configured just to be ssh://review/mediawiki/core.git
and I have "review" set up in $HOME/.ssh/config.

Unfortunately, I need to change git remote URLs to make sure
the repository is linked from Special:Version.

This shouldn't be necessary; either we should fallback to the
official MediaWiki git repository or we should add the configuration
option to adapt to local needs.

Change-Id: I2e0b6470c16ec36d0e94cceab844f4a4c4334067

RELEASE-NOTES-1.20
includes/DefaultSettings.php
includes/GitInfo.php

index c41550e..2d58573 100644 (file)
@@ -15,6 +15,8 @@ Since 1.20, the lowest supported version of PHP is now 5.3.2. Please
 upgrade PHP if you have not done so prior to upgrading MediaWiki.
 
 === Configuration changes in 1.20 ===
+* $wgGitRepositoryViewers defines a mapping from Git remote repository to the
+  Gitweb instance URL used in Special:Version
 * `$wgUsePathInfo = true;` is no longer needed to make $wgArticlePath work on servers
   using like nginx, lighttpd, and apache over fastcgi. MediaWiki now always extracts
   path info from REQUEST_URI if it's available.
index d3c24ca..d05f020 100644 (file)
@@ -4562,6 +4562,20 @@ $wgReadOnlyFile = false;
  */
 $wgUpgradeKey = false;
 
+/**
+ * Map GIT repository URLs to viewer URLs to provide links in Special:Version
+ *
+ * Key is a pattern passed to preg_match() and preg_replace(),
+ * without the delimiters (which are #) and must match the whole URL.
+ * The value is the replacement for the key (it can contain $1, etc.)
+ * %h will be replaced by the short SHA-1 (7 first chars) and %H by the
+ * full SHA-1 of the HEAD revision.
+ */
+$wgGitRepositoryViewers = array(
+    'https://gerrit.wikimedia.org/r/p/(.*)' => 'https://gerrit.wikimedia.org/r/gitweb?p=$1;h=%H',
+    'ssh://(?:[a-z0-9_]+@)?gerrit.wikimedia.org:29418/(.*)' => 'https://gerrit.wikimedia.org/r/gitweb?p=$1;h=%H',
+);
+
 /** @} */ # End of maintenance }
 
 /************************************************************************//**
index b15cedd..e1b0379 100644 (file)
@@ -187,20 +187,10 @@ class GitInfo {
         * @return array
         */
        protected static function getViewers() {
-               if( self::$viewers === false ) {
-
-                       // Map of repo URLs to viewer URLs.
-                       //
-                       // Key is a pattern passed to preg_match() and preg_replace(),
-                       // without the delimiters (which are #) and must match the whole URL.
-                       // The value is the replacement for the key (it can contain $1, etc.)
-                       // %h will be replaced by the short SHA-1 (7 first chars) and %H by the
-                       // full SHA-1 of the HEAD revision.
-                       self::$viewers = array(
-                               'https://gerrit.wikimedia.org/r/p/(.*)' => 'https://gerrit.wikimedia.org/r/gitweb?p=$1;h=%H',
-                               'ssh://(?:[a-z0-9_]+@)?gerrit.wikimedia.org:29418/(.*)' => 'https://gerrit.wikimedia.org/r/gitweb?p=$1;h=%H',
-                       );
+               global $wgGitRepositoryViewers;
 
+               if( self::$viewers === false ) {
+                       self::$viewers = $wgGitRepositoryViewers;
                        wfRunHooks( 'GitViewers', array( &self::$viewers ) );
                }