My favorites | Sign in
Project Home Downloads Wiki Issues Source
New issue   Search
for
  Advanced search   Search tips   Subscriptions
Issue 3286: Add support for syntax highlighting of puppet files
2 people starred this issue and may be notified of changes. Back to list
Status:  Duplicate
Merged:  issue 3293
Owner:  ----
Closed:  Apr 2015


Sign in to add a comment
 
Project Member Reported by zaro0508, Apr 9, 2015
setting mimetype in gerrit.config should allow users to download the file directly instead of being wrapped up inside of zipped archives however that doesn't seem to work.

https://gerrit-review.googlesource.com/Documentation/config-gerrit.html#mimetype

Affected Version:  2.8.4 & 2.9.4

What steps will reproduce the problem?
1. add following to gerrit.config and restart gerrit:

[mimetype "text/yaml"]
        safe = true
[mimetype "application/yaml"]
        safe = true

2. push a yaml change containing a yaml file to gerrit
3. click on file to go into review screen
4. click the download icon.

What is the expected output? What do you see instead?
I expect just the yaml file, however the download is a zip file.

Apr 9, 2015
Project Member #1 dougk....@gmail.com
From IRC:

I'm fairly sure this is happening because mime-util doesn't know the yaml file extension, but adding the extension as documented in http://mime-util.sourceforge.net/apidocs/eu/medsea/mimeutil/detector/ExtensionMimeDetector.html should work:

For example, in ~/.mime-types.properties, add:
yaml=text/yaml
Apr 9, 2015
Project Member #2 david.pu...@sonymobile.com
(No comment was entered for this change.)
Status: AwaitingInformation
Apr 12, 2015
Project Member #3 zaro0508
I added the mime-types file to the home directory as suggested in the mime-util doc.  I also tried to add the file to the classpath using JAVA_OPTS and putting it in the $GERRIT_SITE/lib folder.  None of those options allowed direct download of yaml files.

I was however able to make it work by changing 'yaml' to 'x-yaml' in gerrit.config like so:

  [mimetype "text/x-yaml"]
       safe = true

Therefore I think that setting it in gerrit.config does the override to mime-util.  However neither 'yaml' nor 'x-yaml' is defined in mime-util's magic.mime and mim-types.properties so it's still a mystery to me how setting 'x-yaml' in gerrit.config makes it work.

I want to add other files, like puppet (*.pp extension) to direct download list but still don't know how to do that. I've tried 'text/pp', 'text/x-pp' and 'text/x-puppet' but none of those work.

Apr 13, 2015
Project Member #4 zaro0508
I believe I've figured this out.  Looks like support for direct downloads is dependent on CodeMirror[1].  CodeMirror defines the mime-type 'x-yaml' [2] which is supported in gerrit and that's why it works.  CodeMirror also defined the mime-type 'x-puppet' [3] however Gerrit does not have support for reviewing puppet code and  that's why direct downlod doesn't work.  

[1] http://codemirror.net/mode/index.html
[2] http://codemirror.net/mode/yaml/index.html
[3] http://codemirror.net/mode/puppet/index.html

Apr 13, 2015
Project Member #5 zaro0508
Fix for  issue 3293  will fix direct downloads for puppet files.  Just add the following to gerrit.config:

  [mimetype "text/x-puppet"]
       safe = true

Status: ChangeUnderReview
Apr 13, 2015
Project Member #7 david.pu...@sonymobile.com
(No comment was entered for this change.)
Summary: Add support for syntax highlighting of puppet files (was: setting mimetype does not allow direct downloading of files)
Labels: -Type-Bug Type-Feature
Apr 13, 2015
Project Member #8 david.pu...@sonymobile.com
(No comment was entered for this change.)
Status: Duplicate
Mergedinto: 3293
Sign in to add a comment

Powered by Google Project Hosting