You are browsing a read-only backup copy of Wikitech. The live site can be found at wikitech.wikimedia.org

Template:Gitweb/doc: Difference between revisions

From Wikitech-static
Jump to navigation Jump to search
imported>Krinkle
 
imported>Gergő Tisza
No edit summary
Line 7: Line 7:


== Usage ==
== Usage ==
  <nowiki>{{Gitweb</nowiki> |project=mediawiki/extensions/''examples'' |file=''BoilerPlate/README'' }}
  <nowiki>{{Gitweb</nowiki> |project=mediawiki/extensions/''examples'' |file=''Example/Example.php'' }}
produces
produces
:{{git_file|project=mediawiki/extensions/examples|file=BoilerPlate/README }}
:{{git_file|project=mediawiki/extensions/examples|file=Example/Example.php }}


  <nowiki>{{Gitweb</nowiki> |project=mediawiki/extensions/ArticleFeedback  
  <nowiki>{{Gitweb</nowiki> |project=mediawiki/extensions/ArticleFeedback  
Line 40: Line 40:
<!-- PUT HERE THE CATEGORIES OF THE TEMPLATE -->
<!-- PUT HERE THE CATEGORIES OF THE TEMPLATE -->
[[Category:Git]]
[[Category:Git]]
</includeonly>
</includeonly><div style="display: none;"><templatedata>
{
"params": {
"project": {
"label": "Project",
"description": "Project (repo) name",
"example": "mediawiki/core",
"type": "string",
"required": true
},
"file": {
"label": "File",
"description": "File name within repo",
"example": "doc/README.md",
"type": "string"
},
"text": {
"label": "Link text",
"type": "string"
}
},
"description": "Adds link to repo/file",
"format": "inline"
}
</templatedata></div>

Revision as of 16:58, 20 July 2018

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").

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/...
  • add branch= parameter
<templatedata>

{ "params": { "project": { "label": "Project", "description": "Project (repo) name", "example": "mediawiki/core", "type": "string", "required": true }, "file": { "label": "File", "description": "File name within repo", "example": "doc/README.md", "type": "string" }, "text": { "label": "Link text", "type": "string" } }, "description": "Adds link to repo/file", "format": "inline" }

</templatedata>