Template:Git file/doc
This is a documentation subpage for Template:Git file. It contains usage information, categories and other content that is not part of the original template page. |
Usage
Generates a link to view the file in Diffusion (Phabricator).
Parameter | Description | Type | Status | |
---|---|---|---|---|
Label | text | The text that become the link.
| String | optional |
Mode | action | One of "browse" or "raw"
| String | optional |
Repository | project | Which Git repository the file is in.
| String | optional |
Branch | branch | Which branch of the repository the file is in.
| String | optional |
Commit | sha | The SHA-1 hash of the specific commit within a branch. Use this to make a permalink. | String | optional |
File | file | Path to the file within the specified repository and branch.
| String | required |
Line number | line | The link will anchor to this line within the file, and highlight it.
| Number | optional |
Example
- Basic
{{git file |file=composer.json }}
produces
{{git file |project=mediawiki/extensions/Flow |file=FlowActions.php }}
produces
- text
{{git file |project=mediawiki/extensions/EventLogging |file=server/bin/eventlogging-devserver |text=development server }}
produces
- action
{{git file |file=composer.json |action=raw }} {{git file |file=composer.json |action=blame }} {{git file |file=composer.json |action=history }}
produces
{{git file |project=mediawiki/extensions/EventLogging |text=EventLogging extension |action=tree }}
produces
- line number
{{git file |file=tests/phpunit/includes/MessageTest.php |line=123 }}
produces
- project summary page (deprecated)
{{git file |project=oojs/core |action=summary |text=OOjs (core)}}
produces
^ 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
Notes
The template has to use numeric entities ;
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
- 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}}