godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.16k stars 97 forks source link

Make a way to ignore such files when they are downloaded from Godot Assets #3648

Closed gumaciel closed 2 years ago

gumaciel commented 2 years ago

Describe the project you are working on

A Plugin for using AdMob in Godot, which will simplify very much the way using Ads on games: https://github.com/Poing-Studios/godot-admob-editor

Describe the problem or limitation you are having in your project

Currently when the user tries to download the Plugin for the "AssetLib" tab, the Asset installer tries to install all the files (except the conflicted ones), and currently I don't see any way to prevent this

Captura de Tela 2021-12-08 às 17 05 40

For example, in this print I would like the files/folders to be unmarked:

"test.tres" "README.MD" "LICENSE" ".gitignore" ".github/"

Leaving only the "addons/" folder available: Captura de Tela 2021-12-08 às 17 08 42

Describe the feature / enhancement and how it helps to overcome the problem or limitation

I think a good way to solve this problem would be to create an extension called .godotignoreassetinstaller (probably with a shorter name) and inside it I could put the files that can be ignored, this file would be rooted in the repository, similar to .gitignore

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

.godotignoreassetinstaller

test.tres README.MD LICENSE .gitignore .github/

Example file is attached bellow: godotignoreassetinstaller.zip

If this enhancement will not be used often, can it be worked around with a few lines of script?

I don't think so

Is there a reason why this should be core and not an add-on in the asset library?

I think theres no way to do that on asset library

YuriSizov commented 2 years ago

Godot simply downloads the ZIP file provided by GitHub and GitLab. There is no pre-processing of any kind, so the proposed solution wouldn't be possible.

Luckily, you can exclude files from getting into the ZIP by using the .gitattributes file. See the example in the docs: https://docs.godotengine.org/en/stable/tutorials/assetlib/uploading_to_assetlib.html#recommendations

gumaciel commented 2 years ago

It works, thank you so much!

https://github.com/Poing-Studios/godot-admob-editor/blob/b5733674d6c2ded4e7dc3f9d87dbfe156c58c905/.gitattributes

nathanfranke commented 2 years ago

Addons example with comments and normalized EOL.

# Normalize EOL for all files that Git considers text files.
* text=auto eol=lf

# Ignore everything outside of the addons folder when exporting.
/**        export-ignore
/addons    !export-ignore
/addons/** !export-ignore

For those who are about to spend 20 minutes trying to simplify this further, note that both lines for /addons are required. The first one inverts the attribute on the folder itself, and the second line inverts the attribute recursively on all files within.

To test, use this command: git archive --format=zip --output project.zip HEAD (Thanks @gumaciel)