Template:Git file
From Wikitech
(Difference between revisions)
Ori.livneh (Talk | contribs) m (Imported template from mw.org) |
|||
| Line 1: | Line 1: | ||
[https://gerrit.wikimedia.org/r/gitweb?p={{{project}}}.git;f={{{file|}}};hb=HEAD;a={{{action|blob}}} {{#if:{{{text|}}}|{{{text}}}|{{{file}}}}}]<noinclude> | [https://gerrit.wikimedia.org/r/gitweb?p={{{project}}}.git;f={{{file|}}};hb=HEAD;a={{{action|blob}}} {{#if:{{{text|}}}|{{{text}}}|{{{file}}}}}]<noinclude> | ||
| − | {{ | + | {{documentation}} |
</noinclude> | </noinclude> | ||
Latest revision as of 23:59, 26 February 2013
This generates a link to a file on Gerrit.
The goal is to avoid ugly URLs like
https://gerrit.wikimedia.org/r/gitweb?p=mediawiki/extensions/examples.git;f=BoilerPlate/README;hb=HEAD
and also future-proof (ha ha) these links against changes and evolution to source code control.
Contents |
[edit] Usage
{{git_file |project=mediawiki/extensions/examples |file=BoilerPlate/README }}
produces
{{git_file |project=mediawiki/extensions/ArticleFeedback
|file=modules/jquery.articleFeedback/images/star-new-down.png
|text=star image | action=blob_plain }}
produces star image
[edit] Parameters
- project
- mandatory. Must be entire path to project — always (?) mediawiki/ , usually extensions, then your project — but not the .git
- file
- mandatory. The file within the project. If you just want to link to the project, use {{gitweb}}. Note this template can be invoked as {{git file}} but to avoid confusion you may want to stick with {{git_file | file=name}}.
- text
- optional. The text that's linked. If not specified, defaults to file.
- action
- optional. You can give a gerrit action, e.g. action=blob_raw, TODO: what are they?
[edit] Issues
- every gerrit project is under mediawiki/ and most under extensions, so maybe one or both is redundant?
- why does the semicolon in the {{#if: TEST|;need that semicolon|}} test introduce whitespace? (Workaround is to use HTML entity ; )
- action= is gerrit-specific, maybe abstract away from gerrit to format=raw/mimetype/...
- add branch= parameter
- TODO: Merge with {{Git}}, or maybe {{Gerrit}}, {{MW file}}, etc. but simpler.
[edit] See also
- {{MW file}} generates complicated link to file, used by Manual
- lots of other fancy templates for extensions on gerrit, see Category:Git