diff --git a/RELEASE-NOTES-1.20 b/RELEASE-NOTES-1.20 index c41550ec201..2d5857311d2 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 d3c24ca301d..d05f02073d1 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 b15cedd8771..e1b0379b6cc 100644 --- a/includes/GitInfo.php +++ b/includes/GitInfo.php @@ -187,20 +187,10 @@ class GitInfo { * @return array */ protected static function getViewers() { + global $wgGitRepositoryViewers; + 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', - ); - + self::$viewers = $wgGitRepositoryViewers; wfRunHooks( 'GitViewers', array( &self::$viewers ) ); }