Template:Git file

From mediawiki.org
Jump to navigation Jump to search

{{{file}}}

Template documentation


Usage[edit]

Generates a link to view the file in Gerrit.

Template parameters

This template prefers inline formatting of parameters.

ParameterDescriptionTypeStatus
Labeltext

The text that become the link.

Default
The 'file' parameter value.
Stringoptional
Modeaction

One of "browse", "tree" or "blame" or "history"

Default
browse
Stringoptional
Repositoryproject

Which Git repository the file is in.

Default
mediawiki/core
Stringoptional
Branchbranch

Which branch of the repository the file is in.

Default
HEAD
Stringoptional
Commitsha

The SHA-1 hash of the specific commit within a branch. Use this to make a permalink.

Stringoptional
Filefile

Path to the file within the specified repository and branch.

Example
includes/MediaWiki.php
Stringrequired
Line numberline

The link will anchor to this line within the file, and highlight it.

Example
42
Numberoptional


Example[edit]

Basic
{{git file |file=composer.json }}

produces

composer.json
{{git file |project=mediawiki/extensions/Flow |file=FlowActions.php }}

produces

FlowActions.php
text
{{git file |project=mediawiki/extensions/EventLogging 
|file=devserver/bin/eventlogging-devserver
|text=development server }}

produces

development server
action
{{git file |file=composer.json |action=raw }}
{{git file |file=composer.json |action=blame }}
{{git file |file=composer.json |action=history }}

produces

composer.json
composer.json
composer.json
{{git file |project=mediawiki/extensions/EventLogging |text=EventLogging extension |action=tree }}

produces

EventLogging extension
line number
{{git file |file=tests/phpunit/includes/MessageTest.php |line=123 }}

produces

tests/phpunit/includes/MessageTest.php
project summary page (deprecated)
{{git file |project=oojs/core |action=summary |text=OOjs (core)}}

produces

OOjs (core)

Known issues[edit]

Notes[edit]

The template has to use numeric entities &#59; and &32; for semicolon and hashmark because, as WP:Advanced template coding says, "MediaWiki wiki-formats the clauses inside #if". MediaWiki would sometimes parse these characters as introducing a definition term and numbered list (even though they're not at the start of new lines!).

See also[edit]