You are browsing a read-only backup copy of Wikitech. The live site can be found at wikitech.wikimedia.org
Module:Gerrit: Difference between revisions
imported>Ori.livneh m (Reverted edits by Ori.livneh (talk) to last revision by Anomie) |
imported>Dereckson (Update URLs to new Gerrit version. Tested and works fine {{Gerrit|I267421c9af6f79b10f8c657a74e7ce89e08560d7}} and {{Gerrit|288158}}.) |
||
Line 14: | Line 14: | ||
text = hash | text = hash | ||
end | end | ||
return '<span class=plainlinks style="font-family: Consolas, Liberation Mono, Courier, monospace; text-decoration: none;">[ | |||
local url | |||
if length > 6 then | |||
-- query | |||
url = 'https://gerrit.wikimedia.org/r/#/q/' .. mw.uri.encode(hash) | |||
else | |||
-- probably a change | |||
url = 'https://gerrit.wikimedia.org/r/#/c/' .. hash .. '/' | |||
end | |||
return '<span class=plainlinks style="font-family: Consolas, Liberation Mono, Courier, monospace; text-decoration: none;">[' .. url .. ' ' .. text .. ']</span>' | |||
end | end | ||
} | } | ||
return gerrit | return gerrit |
Revision as of 22:06, 25 July 2016
Lua error in Module:TNT at line 158: Missing JsonConfig extension; Cannot load https://commons.wikimedia.org/wiki/Data:I18n/Lua banner.tab.
Usage examples
Without any parameter
Wikitext: {{Gerrit}}
Render:
- example
Link to a change
Wikitext: {{Gerrit|4203}}
Render a link to change number 4203:
With deploy commands
Wikitext: {{Gerrit|688200|bacc=y}}
Render:
On the deployment calendar bacc is enabled by default.
Link to Gerrit change id
Wikitext: {{Gerrit|I2d7d6eeef07552b796a68963ccd4f89f4c5939d7}}
Render:
Link to Git commit hash
Wikitext: {{Git|3b85ab0624afe5a53bb60c558f0bef4d6dfb43cd}}
Render:
Wikitext: {{Git|3b85ab0}}
Render:
Parameters description
<templatedata> { "params": { "1": { "label": "Identifier", "description": "The git commit hash, gerrit change number, or gerrit Change-Id", "type": "string", "required": true, "suggested": true } }, "format": "inline" } </templatedata>
local gerrit = {
link = function (frame)
local hash = frame.args[1]
local length = string.len(hash)
if not string.match(hash, '^I?%x+$' ) then
return hash
end
local text
if length > 14 then
text = string.format("%.7s", hash)
else
text = hash
end
local url
if length > 6 then
-- query
url = 'https://gerrit.wikimedia.org/r/#/q/' .. mw.uri.encode(hash)
else
-- probably a change
url = 'https://gerrit.wikimedia.org/r/#/c/' .. hash .. '/'
end
return '<span class=plainlinks style="font-family: Consolas, Liberation Mono, Courier, monospace; text-decoration: none;">[' .. url .. ' ' .. text .. ']</span>'
end
}
return gerrit