Difference between revisions 585541 and 585562 on mediawikiwiki<noinclude>{{Documentation subpage}} {{timw|{{BASEPAGENAME}}}} </noinclude> <!-- PUT HERE THE DOCUMENTATION --> This generates a link to a file on [[Gerrit]]. The goal is to avoid ugly URLs in wiki text 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 such as swapping gitweb for GitBlit ({{bug|38383}}). == Usage == <nowiki>{{git_file</nowiki> |project=mediawiki/extensions/''examples'' |file=''BoilerPlate/README'' }} produces :{{git_file|project=mediawiki/extensions/examples|file=BoilerPlate/README }} ⏎ ⏎ <nowiki>{{git_file</nowiki> |project=mediawiki/extensions/ArticleFeedback |file=modules/jquery.articleFeedback/images/star-new-down.png |text=star image | action=blob_plain }} produces :{{git_file|project=mediawiki/extensions/ArticleFeedback |file=modules/jquery.articleFeedback/images/star-new-down.png |text=star image |action=blob_plain}}⏎ Alas, the line parameter <nowiki>{{git_file |file=tests/phpunit/includes/IPTest.php |line=123}}</nowiki> produces :{{git_file |file=tests/phpunit/includes/IPTest.php |line=123}} ''help needed with the misery of curly braces and semicolons and link parsing'' === Parameters === ; project : mandatdefaults to mediawiki/corye. Must be entire path to project — always (?)usually mediawiki/ , usuallyoften extensions/, then your project — but not the <tt>.git</tt> ; file : mandatory. TheA file or directory within the project. If you just want to link to the project, use {{tl|gitweb}}. Note this template can be invoked as {{tl|git file}} but to avoid confusion you may want to stick with <nowiki>{{git_o avoid confusion you may want to invoke this template with underscore <nowiki>{{git</nowiki>'''_'''file | file=</nowiki>''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. Also , action=tree (gerrit/gitweb should be smart enough to infer thisinfers this if file= a directory)... ''TODO: what are the other values?'' ; line : optional. line=42 will add a fragment to the URL that positions the browser at line 42 of the file. ''Except for bugs, help needed'' == Issues == * every gerrit project is under mediawiki/ and most under extensions, so maybe one or both is redundant? * why does the semicolon in the <nowiki>{{#if: TEST|;need that semicolon|}}</nowiki> test introduce whitespace? (Workaround is to use HTML entity &#59; ) * action= is gerrit-specific, maybe abstract away from gerrit to format=raw/''mimetype''/... * TODO: add branch= parameter * '''TODO''':: fix line=nnn misery * ? Merge with {{tl|Git}}, or maybe {{tl|Gerrit}}, {{tl|MW file}}, etc. but simpler.? == See also == * this replaces Template:GitwebFile that had almost exactly the same functionality (but undocumented and uncategorized so spage missed it) * {{tl|MW file}} generates complicated link to file, used by [[Manual]] * lots of other fancy templates for extensions on gerrit, see [[:Category:Git]] <includeonly> <!-- PUT HERE THE CATEGORIES OF THE TEMPLATE --> [[Category:Git]] </includeonly> All content in the above text box is licensed under the Creative Commons Attribution-ShareAlike license Version 4 and was originally sourced from https://mediawiki.org/w/index.php?diff=prev&oldid=585562.
![]() ![]() This site is not affiliated with or endorsed in any way by the Wikimedia Foundation or any of its affiliates. In fact, we fucking despise them.
|