From: saper Date: Sun, 6 May 2012 20:12:14 +0000 (+0200) Subject: $wgGitRepositoryViewers to link to gitweb X-Git-Tag: 1.31.0-rc.0~23715^2 X-Git-Url: http://git.cyclocoop.org/%24href?a=commitdiff_plain;h=8bab490decd0978ea945e0ca24b339ce2881187a;p=lhc%2Fweb%2Fwiklou.git $wgGitRepositoryViewers to link to gitweb 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 --- diff --git a/RELEASE-NOTES-1.20 b/RELEASE-NOTES-1.20 index c41550ec20..2d5857311d 100644 --- a/RELEASE-NOTES-1.20 +++ b/RELEASE-NOTES-1.20 @@ -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. diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index d3c24ca301..d05f02073d 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -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 } /************************************************************************//** diff --git a/includes/GitInfo.php b/includes/GitInfo.php index b15cedd877..e1b0379b6c 100644 --- a/includes/GitInfo.php +++ b/includes/GitInfo.php @@ -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 ) ); }