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>Krinkle
No edit summary
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<!-- PUT HERE THE DOCUMENTATION -->
<!-- PUT HERE THE DOCUMENTATION -->
{{see also|Template:Gerrit|Template:Git repo}}
This generates a link to a file on [[Gerrit]].
This generates a link to a file on [[Gerrit]].


The goal is to avoid ugly URLs like
The goal is to avoid manual URLs like
   https://gerrit.wikimedia.org/r/gitweb?p=mediawiki/extensions/examples.git;f=BoilerPlate/README;hb=HEAD
   https://gerrit.wikimedia.org/g/mediawiki/extensions/examples/+/HEAD/extension.json
and also future-proof (ha ha) these links against changes and evolution to source code control.
 
and also future-proof against changes and evolution to source code viewers.


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


  <nowiki>{{Gitweb</nowiki> |project=mediawiki/extensions/ArticleFeedback
  <nowiki>{{Gitweb</nowiki> |project=mediawiki/extensions/examples |file=extension.json| text=''important file'' }}
|file=modules/jquery.articleFeedback/images/star-new-down.png
|text=star image | action=blob_plain }}
produces
produces
: {{Gitweb|project=mediawiki/extensions/ArticleFeedback
:{{git_file|project=mediawiki/extensions/examples|file=extension.json|text=important file}}
|file=modules/jquery.articleFeedback/images/star-new-down.png
|text=star image |action=blob_plain}}


  <nowiki>{{Gitweb</nowiki> |project=operations/apache-config|action=summary}}
  <nowiki>{{Gitweb</nowiki> |project=operations/mediawiki-config}}
produces
produces
:{{Gitweb|project=operations/apache-config|action=summary}}
:{{Gitweb|project=operations/mediawiki-config}}


=== Parameters ===
=== Parameters ===
; project
; project
: mandatory. Must be entire path to project &mdash; always (?) mediawiki/ , usually extensions, then your project &mdash; but not the <tt>.git</tt>
: mandatory. Full name of the Git repository, including any "mediawiki/extensions/" or "operations/" prefix, but without <code>.git</code> suffix.
; file
; file
: optional. The path within the project.
: optional. Link to a file within the project, instead of linking to the repository summary page.
; text
; text
: optional. The text that's linked.  If not specified, defaults to file and then to project.
: optional. Link label text.  If not specified, defaults to file name or project name.
; action
; action
: optional. You can give a gitweb action, such as "summary", "tree", "blob", "blob_plain" (defaults to "blob").
: ignored. (Existed in the past for use with Gitweb, but we now use Gitiles.)
 
; branch
== Issues ==
: optional. The branch in the git repo, default 'master' (unless project=operations/puppet, in which case, default 'production')
* why does the semicolon in the <nowiki>{{#if: TEST|;need that semicolon|}}</nowiki> test introduce whitespace?  (Workaround is to use HTML entity &amp;#59; )
* action= is gitweb-specific, maybe abstract to format=raw/''mimetype''/...
* add branch= parameter
<includeonly>
<includeonly>
<!-- PUT HERE THE CATEGORIES OF THE TEMPLATE -->
<!-- PUT HERE THE CATEGORIES OF THE TEMPLATE -->
[[Category:Git]]
[[Category:Git]]
</includeonly>
</includeonly>
== TemplateData ==
<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"
},
"branch": {
"label": "Git branch (default 'master')",
"type": "string"
}
},
"description": "Adds link to repo/file",
"format": "inline"
}
</templatedata>

Latest revision as of 19:41, 26 July 2022

This generates a link to a file on Gerrit.

The goal is to avoid manual URLs like

 https://gerrit.wikimedia.org/g/mediawiki/extensions/examples/+/HEAD/extension.json

and also future-proof against changes and evolution to source code viewers.

Usage

{{Gitweb |project=mediawiki/extensions/examples |file=extension.json }}

produces

extension.json
{{Gitweb |project=mediawiki/extensions/examples |file=extension.json| text=important file }}

produces

important file
{{Gitweb |project=operations/mediawiki-config}}

produces

operations/mediawiki-config

Parameters

project
mandatory. Full name of the Git repository, including any "mediawiki/extensions/" or "operations/" prefix, but without .git suffix.
file
optional. Link to a file within the project, instead of linking to the repository summary page.
text
optional. Link label text. If not specified, defaults to file name or project name.
action
ignored. (Existed in the past for use with Gitweb, but we now use Gitiles.)
branch
optional. The branch in the git repo, default 'master' (unless project=operations/puppet, in which case, default 'production')

TemplateData

<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" }, "branch": { "label": "Git branch (default 'master')", "type": "string" } }, "description": "Adds link to repo/file", "format": "inline" } </templatedata>