Jump to content

Manual:$wgGitRepositoryViewers: Difference between revisions

From mediawiki.org
Content deleted Content added
m -redlink
m update default values
 
(30 intermediate revisions by 11 users not shown)
Line 1: Line 1:
<languages/>
{{SettingSummary
{{SettingSummary
| name=SQLiteDataDirMode
| name=GitRepositoryViewers
| version_min=1.20.0
| version_min=1.20.0
| sha_introduced=8bab490decd0978ea945e0ca24b339ce2881187a
| sha_introduced=8bab490decd0978ea945e0ca24b339ce2881187a
| change_introduced=6776
| version_max =
| version_max =
| section=Maintenance Scripts setting
| section=Maintenance Scripts setting
| range=(array)
| range=(<translate><!--T:14--> array</translate>)
| default=<syntaxhighlight lang="php">
| default=(''<translate><!--T:15--> see below</translate>'')
| summary=<translate><!--T:2--> Map of Git repository URLs to their gitweb interface URLs</translate>
array(
}}
'https://gerrit.wikimedia.org/r/p/(.*)' => 'https://gerrit.wikimedia.org/r/gitweb?p=$1;h=%H',
<translate>
'ssh://(?:[a-z0-9_]+@)?gerrit.wikimedia.org:29418/(.*)' => 'https://gerrit.wikimedia.org/r/gitweb?p=$1;h=%H',
== Details == <!--T:3-->
</translate>
<translate><!--T:4--> Maps Git repository URLs to viewer URLs to provide links in [[<tvar|version>Special:Version</>|Special:Version]].</translate>
<translate><!--T:17--> [[<tvar|version>Special:Version</>|Special:Version]] looks up git ''remote'' configuration and identifies a correct git ''remote'' entry for the branch of code that is currently being run.</translate>

<translate>
<!--T:5-->
This URL needs to be converted in to the gitweb interface URL (if available), so that git revision identifiers (in the form of SHA-1 hash) can be linked to the repository viewer.
</translate>

<translate><!--T:6--> This variable is an array of (key, value) pairs, the key is used to look up the git ''remote'' entry URL.</translate>
<translate><!--T:18--> The key is a pattern passed to preg_match() and preg_replace(), without the delimiters (which are #) and must match the whole URL.</translate>

<translate><!--T:7--> The value is a pattern to obtain a correct URL for the gitweb interface.</translate>
<translate><!--T:19--> The value is the regular expression replacement for the key (it can contain $1, etc.).</translate>
<translate><!--T:20--> '''%h''' will be replaced by the short SHA-1 (7 first chars) and '''%H''' by the full SHA-1 of the HEAD revision.</translate>

<translate>
== Default value == <!--T:16-->
</translate>

{{MW 1.31|+}}{{-}}
<syntaxhighlight lang="php">
$wgGitRepositoryViewers = [
'https://(?:[a-z0-9_]+@)?gerrit.wikimedia.org/r/(?:p/)?(.*)' => 'https://gerrit.wikimedia.org/g/%R/+/%H',
'ssh://(?:[a-z0-9_]+@)?gerrit.wikimedia.org:29418/(.*)' => 'https://gerrit.wikimedia.org/g/%R/+/%H',
];
</syntaxhighlight>

{{MW version|version=1.27|version2=1.30}}{{-}}
<syntaxhighlight lang="php">
$wgGitRepositoryViewers = [
'https://(?:[a-z0-9_]+@)?gerrit.wikimedia.org/r/(?:p/)?(.*)' =>
'https://phabricator.wikimedia.org/r/revision/%R;%H',
'ssh://(?:[a-z0-9_]+@)?gerrit.wikimedia.org:29418/(.*)' =>
'https://phabricator.wikimedia.org/r/revision/%R;%H',
];
</syntaxhighlight>

{{MW version|version=1.24|version2=1.26}}{{-}}
<syntaxhighlight lang="php">
$wgGitRepositoryViewers = array(
'https://(?:[a-z0-9_]+@)?gerrit.wikimedia.org/r/(?:p/)?(.*)' =>
'https://git.wikimedia.org/tree/%r/%H',
'ssh://(?:[a-z0-9_]+@)?gerrit.wikimedia.org:29418/(.*)' =>
'https://git.wikimedia.org/tree/%r/%H',
);
);
</syntaxhighlight>
</syntaxhighlight>
| summary=Map of Git repository URLs to their gitweb interface URLs
}}


{{MW 1.23}}{{-}}
== Details ==
<syntaxhighlight lang="php">
Maps GIT repository URLs to viewer URLs to provide links in [[Special:Version]]. [[Special:Version]] looks up
$wgGitRepositoryViewers = array(
git ''remote'' configuration and identifies a correct git ''remote'' entry for the branch of code that is currently
'https://(?:[a-z0-9_]+@)?gerrit.wikimedia.org/r/(?:p/)?(.*)' =>
being run.
'https://git.wikimedia.org/commit/%r/%H',
'ssh://(?:[a-z0-9_]+@)?gerrit.wikimedia.org:29418/(.*)' =>
'https://git.wikimedia.org/commit/%r/%H',
);
</syntaxhighlight>


{{MW 1.22}}{{-}}
This URL needs to be converted in to the gitweb interface URL (if available), so that git revision identifiers (in the form of SHA-1 hash) can be linked to the repository viewer.
<syntaxhighlight lang="php">
$wgGitRepositoryViewers = array(
'https://gerrit.wikimedia.org/r/p/(.*)' => 'https://git.wikimedia.org/commit/%r/%H',
'ssh://(?:[a-z0-9_]+@)?gerrit.wikimedia.org:29418/(.*)'
=> 'https://git.wikimedia.org/commit/%r/%H',
);
</syntaxhighlight>


{{MW version|version=1.20|version2=1.21}}{{-}}
This variable is an array of (key, value) pairs, the key is used to look up the git ''remote'' entry URL.
<syntaxhighlight lang="php">
The key is a pattern passed to preg_match() and preg_replace(), without the delimiters (which are #) and must match the whole URL.
$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',
);
</syntaxhighlight>


<translate>
The value is a pattern to obtain a correct URL for the gitweb interface. The value is the regular expression 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.
== Example == <!--T:8-->


<!--T:9-->
{{Languages}}
If you have the following entry in ''.ssh/config'' (as described in [[<tvar|gerrit-adv>Special:MyLanguage/Gerrit/Advanced usage#Setup SSH shortcut (optional)</>|Setup SSH shortcut]]):
</translate>

<syntaxhighlight lang="ini" style="overflow:auto;">
Host review
Hostname gerrit.wikimedia.org
Port 29418
User username
</syntaxhighlight>

<translate>
<!--T:10-->
And if your git ''remote'' used to fetch MediaWiki is configured in the following way in ''.git/config'':
</translate>

<syntaxhighlight lang="ini" style="overflow:auto;">
[remote "review"]
url = ssh://review/mediawiki/core.git
fetch = +refs/heads/*:refs/remotes/review/*
</syntaxhighlight>

<translate>
<!--T:11-->
then this entry in <tvar|1>{{ll|Manual:LocalSettings.php|LocalSettings.php}}</> will make <tvar|2><code>ssh://review/mediawiki/core.git</code></> URL to be recognized as pointing to the [[<tvar|3>Special:MyLanguage/Gerrit</>|Wikimedia git repository]]:
</translate>

<syntaxhighlight lang="php" style="overflow:auto;">
$wgGitRepositoryViewers['ssh://(?:[a-z0-9_]+@)?review/(.*)'] = 'https://gerrit.wikimedia.org/r/gitweb?p=$1;h=%H';
</syntaxhighlight>

<translate>
== GitHub == <!--T:12-->

<!--T:13-->
When using extensions that are maintained at GitHub, you can use this to link them.
</translate>

<syntaxhighlight lang="php" style="overflow:auto;">
$wgGitRepositoryViewers['https://github.com/(.*?)(.git)?'] = 'https://github.com/$1/commit/%H';
</syntaxhighlight>

Latest revision as of 08:33, 19 March 2022

Maintenance scripts setting: $wgGitRepositoryViewers
Map of Git repository URLs to their gitweb interface URLs
Introduced in version:1.20.0 (Gerrit change 6776; git #8bab490d)
Removed in version:Still in use
Allowed values:(array)
Default value:(see below)

Details

[edit]

Maps Git repository URLs to viewer URLs to provide links in Special:Version. Special:Version looks up git remote configuration and identifies a correct git remote entry for the branch of code that is currently being run.

This URL needs to be converted in to the gitweb interface URL (if available), so that git revision identifiers (in the form of SHA-1 hash) can be linked to the repository viewer.

This variable is an array of (key, value) pairs, the key is used to look up the git remote entry URL. The 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 a pattern to obtain a correct URL for the gitweb interface. The value is the regular expression 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.

Default value

[edit]
MediaWiki version:
1.31
$wgGitRepositoryViewers = [
	'https://(?:[a-z0-9_]+@)?gerrit.wikimedia.org/r/(?:p/)?(.*)' => 'https://gerrit.wikimedia.org/g/%R/+/%H',
	'ssh://(?:[a-z0-9_]+@)?gerrit.wikimedia.org:29418/(.*)' => 'https://gerrit.wikimedia.org/g/%R/+/%H',
];
MediaWiki versions:
1.27 – 1.30
$wgGitRepositoryViewers = [
	'https://(?:[a-z0-9_]+@)?gerrit.wikimedia.org/r/(?:p/)?(.*)' =>
		'https://phabricator.wikimedia.org/r/revision/%R;%H',
	'ssh://(?:[a-z0-9_]+@)?gerrit.wikimedia.org:29418/(.*)' =>
		'https://phabricator.wikimedia.org/r/revision/%R;%H',
];
MediaWiki versions:
1.24 – 1.26
$wgGitRepositoryViewers = array(
	'https://(?:[a-z0-9_]+@)?gerrit.wikimedia.org/r/(?:p/)?(.*)' =>
		'https://git.wikimedia.org/tree/%r/%H',
	'ssh://(?:[a-z0-9_]+@)?gerrit.wikimedia.org:29418/(.*)' =>
		'https://git.wikimedia.org/tree/%r/%H',
);
MediaWiki version:
1.23
$wgGitRepositoryViewers = array(
	'https://(?:[a-z0-9_]+@)?gerrit.wikimedia.org/r/(?:p/)?(.*)' =>
		'https://git.wikimedia.org/commit/%r/%H',
	'ssh://(?:[a-z0-9_]+@)?gerrit.wikimedia.org:29418/(.*)' =>
		'https://git.wikimedia.org/commit/%r/%H',
);
MediaWiki version:
1.22
$wgGitRepositoryViewers = array(
	'https://gerrit.wikimedia.org/r/p/(.*)' => 'https://git.wikimedia.org/commit/%r/%H',
	'ssh://(?:[a-z0-9_]+@)?gerrit.wikimedia.org:29418/(.*)'
		=> 'https://git.wikimedia.org/commit/%r/%H',
);
MediaWiki versions:
1.20 – 1.21
$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',
);

Example

[edit]

If you have the following entry in .ssh/config (as described in Setup SSH shortcut):

Host review
Hostname gerrit.wikimedia.org
Port 29418
User username

And if your git remote used to fetch MediaWiki is configured in the following way in .git/config:

[remote "review"]
	url = ssh://review/mediawiki/core.git
	fetch = +refs/heads/*:refs/remotes/review/*

then this entry in LocalSettings.php will make ssh://review/mediawiki/core.git URL to be recognized as pointing to the Wikimedia git repository:

$wgGitRepositoryViewers['ssh://(?:[a-z0-9_]+@)?review/(.*)'] = 'https://gerrit.wikimedia.org/r/gitweb?p=$1;h=%H';

GitHub

[edit]

When using extensions that are maintained at GitHub, you can use this to link them.

$wgGitRepositoryViewers['https://github.com/(.*?)(.git)?'] = 'https://github.com/$1/commit/%H';