Linguist: Unable to recognise Dockerfiles with extensions

Created on 28 Jun 2019  Â·  8Comments  Â·  Source: github/linguist

Preliminary Steps

Please confirm you have...

Problem Description

We can name a dockerfile multiple ways. Usual way is to name it as it is either Dockerfile or dockerfile in this case GitHub recognizes a dockerfile. But it's a usual practice that developers name them with extensions like Dockerfile.dev or Dockerfile.prod or similar to it. In these case GitHub fails to recognize them as Dockerfiles.

URL of the affected repository:

All repos using Dockerfiles with extensions.
examples:
https://github.com/kmehant/foundation.mozilla.org/blob/master/dockerfiles/Dockerfile.node

Last modified on:

Expected language:


Dockerfile

Detected language:


nothing

Most helpful comment

This is only a smaller part of a larger underlying issue — Linguist has no way of identifying files based upon a common prefix, only a suffix (file extension) or complete filename.

Dockerfiles aren't the only thing affected by this; many Makefiles have suffixes that match their relevant architecture; e.g., Makefile.amd64. I believe we can address this on a broader level if we introduce a new strategy to match prefixes instead of extensions.

All 8 comments

@lildude @Alhadis can you please look in to it?

This issue has been automatically marked as stale because it has not had activity in a long time. If this issue is still relevant and should remain open, please reply with a short explanation (e.g. "I have checked the code and this issue is still relevant because ___."). Thank you for your contributions.

This is only a smaller part of a larger underlying issue — Linguist has no way of identifying files based upon a common prefix, only a suffix (file extension) or complete filename.

Dockerfiles aren't the only thing affected by this; many Makefiles have suffixes that match their relevant architecture; e.g., Makefile.amd64. I believe we can address this on a broader level if we introduce a new strategy to match prefixes instead of extensions.

Ditto Jenkinsfile.whatever (or Jenkinsfile-whatever).

This issue has been automatically marked as stale because it has not had activity in a long time. If this issue is still relevant and should remain open, please reply with a short explanation (e.g. "I have checked the code and this issue is still relevant because ___."). Thank you for your contributions.

Adding my vote for this one, as it impacts Jenkins, Docker, Makefile, and probably several others. If adding a more general regexp matching is complicated, we could probably get a lot of value out of simple prefix matching in the same way we do extension matching - e.g. for Groovy it might look like this:

extensions:
  - ".groovy"
  - ".grt"
  - ".gtpl"
  - ".gvy"
prefixes:
  - "Jenkinsfile."
filenames:
  - Jenkinsfile

I've tentatively started work on this in the prefix-strategy branch. You can track my slow and sporadic bursts of progress there. Hopefully I can implement this without messing with the classifier… 😓

Was this page helpful?
0 / 5 - 0 ratings

Related issues

d4nyll picture d4nyll  Â·  3Comments

FranklinYu picture FranklinYu  Â·  4Comments

henrywright picture henrywright  Â·  6Comments

lucasrodes picture lucasrodes  Â·  6Comments

RafaelPAndrade picture RafaelPAndrade  Â·  4Comments