Template:Git file

From MediaWiki.org
Jump to: navigation, search

{{{file}}}

Documentation icon Template documentation[view] [edit] [history] [purge]

This generates a link to a file in Diffusion (Phabricator).

If this template is not working for a repository, make sure its callsign is listed in Module:Callsigns.

Usage[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.

Parameters[edit]

project
defaults to mediawiki/core. Must be entire path to project — e.g. mediawiki/extensions/EventLogging, not "EventLogging" and without any .git suffix. The template uses Module:Callsigns to map this to a Diffision "callsign", e.g. EEVL.
branch
defaults to HEAD, or you can specify e.g. branch=REL1_25. TODO: unlike old gitblit URLs, this doesn't work to link to a particular commit.
file
optional. A file or directory within the project, without the leading '/'. If you just want to link to the project, use {{gitweb}}. Note to avoid confusion you may want to invoke this template with underscore — {{git_file | file=name}}.
text
optional. The text that's linked. If not specified, defaults to file.
action
optional. You can give a Diffusion view action Gitblit action, e.g. action=raw , action=blame (enables Diffusion "blame mode"), action=history. Use action=tree to link to a directory in the project. Note: Diffusion doesn't support gerrit/gitweb's action blob_plain
line
optional. line=42 will add a fragment to the URL that positions the browser at line 42 of the file.

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