Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not all BUILD files are Starlark (Starlark overrides shell) #5008

Open
4 tasks done
v4hn opened this issue Sep 14, 2020 · 3 comments
Open
4 tasks done

Not all BUILD files are Starlark (Starlark overrides shell) #5008

v4hn opened this issue Sep 14, 2020 · 3 comments
Labels
Add Language Good First Issue This is a great opportunity to start contributing to Linguist

Comments

@v4hn
Copy link

v4hn commented Sep 14, 2020

Preliminary Steps

Please confirm you have...

Problem Description

I had never heard of Starlark before, but apparently it overrides regular shell scripts in many contexts.
Over 50% of our package build instructions which are mostly bash scripts are recognized as Starlark at the moment. Here is one rather clear example, but the search gives you many others.

Adding shebang lines in each file is not an option because it simply bloats all descriptions.
We might add overrides in the future because many of the files are ambiguous with Python as well, but seeing a rather unusual variant of python being detected so prominently seems like an issue that should be resolved.

URL of the affected repository:

https://github.com/lunar-linux/moonbase-core

Last modified on:

2020/09/14

Expected language:

Shell

Detected language:

Starlark

@smola
Copy link
Contributor

smola commented Sep 20, 2020

@v4hn Starlark is the language used by Bazel. Linguist currently classifies BUILD files as Starlark without running any further heuristic.

You can override this with a single .gitattributes file in your repos: https://github.com/github/linguist#overrides

@v4hn v4hn changed the title Starlark overrides simple bash/sh scripts Not all BUILD files are Starlark (Starlark overrides shell) Sep 20, 2020
@v4hn
Copy link
Author

v4hn commented Sep 20, 2020

Thanks for the pointer @smola !
The better solution would be to look into files instead of deciding based on a plain file name without extension. :-)

@lildude
Copy link
Member

lildude commented Oct 28, 2020

The better solution would be to look into files instead of deciding based on a plain file name without extension. :-)

Linguist does, but only if, in this case, the filename is associated with more than one language. As has already been pointed out, BUILD is only associated with one language so Linguist will return that straight away and not look into the content. To get it to move onto the heuristics and later steps that look at the content, support would need to be added for another language.

Please feel free to submit a PR to add support and a heuristic, though adding a heuristic. Given these are shell scripts, and from the few I've looked at in your repo, without shebangs, it might be easier to write the heuristic to identify the Skylark files and fallback to shell.

@lildude lildude added Add Language Good First Issue This is a great opportunity to start contributing to Linguist labels Oct 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Add Language Good First Issue This is a great opportunity to start contributing to Linguist
Projects
None yet
Development

No branches or pull requests

3 participants