Template:Git file/doc

From Wikitech
Jump to: navigation, search

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

Usage

{{git_file |project=mediawiki/extensions/examples |file=BoilerPlate/README }}

produces

BoilerPlate/README
{{git_file |project=mediawiki/extensions/ArticleFeedback 
|file=modules/jquery.articleFeedback/images/star-new-down.png
|text=star image | action=blob_plain }}

produces star image

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?

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 &#59; )
  • 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.

See also

  • {{MW file}} generates complicated link to file, used by Manual
  • lots of other fancy templates for extensions on gerrit, see Category:Git
Personal tools
Namespaces

Variants
Actions
Navigation
Ops documentation
Wiki
Toolbox