Template:Git file

From MediaWiki.org
Jump to navigation Jump to search

{{{file}}}

Documentation icon Template documentation[view] [edit] [history] [purge]
If this template is not working for a repository, make sure its callsign is listed in Module:Callsigns.

Usage[edit]

Generates a link to view the file in Diffusion (Phabricator).

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" or "raw"

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
master
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=server/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)

^ 2015-08-27 this is actually only working by coincidence, https://phabricator.wikimedia.org/diffusion/GOJS/blahblah/anythingUnrecognized also redirects to the simple https://phabricator.wikimedia.org/diffusion/GOJS/ summary page
Instead use the proper {{git repo}} template.

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]

  • This replaces Template:GitwebFile which had almost exactly the same functionality (but undocumented and uncategorized so pages missed it).
  • {{git repo}} links to repo summary
  • {{gitblit}} generates link to repo summary
  • {{MW file}} generates complicated link to file, used by Manual.
  • lots of other fancy templates for extensions on gerrit, see Category:Git.
  • {{github}}

Maintenance: blob_plain, shortlog, Module:Callsigns