Template:Gitweb

From Wikitech
Jump to navigation Jump to search

{{{project}}}

Template documentation

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.

Usage

{{Gitweb |project=mediawiki/extensions/examples |file=Example/Example.php }}

produces

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

produces

star image
{{Gitweb |project=operations/apache-config|action=summary}}

produces

operations/apache-config

Parameters

project
mandatory. Must be entire path to project — always (?) mediawiki/ , usually extensions, then your project — but not the .git
file
optional. The path within the project.
text
optional. The text that's linked. If not specified, defaults to file and then to project.
action
optional. You can give a gitweb action, such as "summary", "tree", "blob", "blob_plain" (defaults to "blob").
branch
optional. The branch in the git repo, default 'master' (unless project=operations/puppet, in which case, default 'production')

Issues

  • why does the semicolon in the {{#if: TEST|;need that semicolon|}} test introduce whitespace? (Workaround is to use HTML entity &#59; )
  • action= is gitweb-specific, maybe abstract to format=raw/mimetype/...

Adds link to repo/file

Template parameters

This template prefers inline formatting of parameters.

ParameterDescriptionTypeStatus
Projectproject

Project (repo) name

Example
mediawiki/core
Stringrequired
Filefile

File name within repo

Example
doc/README.md
Stringoptional
Link texttext

no description

Stringoptional
Git branch (default 'master')branch

no description

Stringoptional