跳转到内容

模板:Git file

来自天灾之下:危险连接资料站
wiki>94rain2023年12月5日 (二) 12:01的版本 (Protected "Template:Git file": Highly visible page or template: 3997 transclusions ([Edit=Allow only autoconfirmed users] (indefinite) [Move=Allow only autoconfirmed users] (indefinite)))
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)

[[git:mediawiki/core/+/HEAD/|]]

模板文档

Usage

Generates a link to view the file in Gerrit.

模板参数[编辑模板数据]

此模板首选参数不换行的行内格式。

参数描述类型状态
Filefile 1

Path to the file within the specified repository and branch.

示例值
includes/MediaWiki.php
字符串必需
Labeltext 2

The text that become the link.

默认值
The “file” parameter value.
字符串可选
Modeaction

One of “browse”, “tree” or “blame” or “history”.

默认值
browse
字符串可选
Repositoryproject

Which Git repository the file is in.

默认值
mediawiki/core
字符串可选
Branchbranch

Which branch of the repository the file is in.

默认值
HEAD
字符串可选
Commitsha

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

字符串可选
Line numberline

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

示例值
42
数字可选


Examples

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}} produces

EventLogging extension
Line number

{{Git file|file=tests/phpunit/includes/SampleTest.php|line=41}} produces

tests/phpunit/includes/SampleTest.php
Project summary page (deprecated)

{{Git file|project=oojs/core|action=summary|text=OOjs (core)}} produces

OOjs (core)

Known issues

Notes

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

  • {{Git repo }} links to a repository summary
  • {{MW file }} generates a box with various links to a file in MediaWiki core, used by Manual.
  • {{Git }} generates links to various git-related objects on gerrit, like commits or changesets
  • {{Github }} links to a file on the GitHub mirror of a repository (by default wikimedia/mediawiki)
  • lots of other fancy templates for extensions on gerrit, see Category:Git.