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

Consider Providing Git Clean Filter to Prevent Plugin Addition #8

Open
knightofiam opened this issue Apr 25, 2023 · 0 comments
Open

Comments

@knightofiam
Copy link

knightofiam commented Apr 25, 2023

Hi, I have git-based Godot projects I want to track time for, but some of them are client projects that wouldn't appreciate this addon being put into their remote repository, when it's for my personal use.

It took quite a while to get this working, but I have created a general git-clean filter that works for project.godot in Godot 3.x, to filter out this plugin addition, regardless of the order of plugins, and regardless of whether the [editor_plugins] section even exists. It will show no changes to project.godot after adding this plugin, upon staging the file (which is when the git clean filter kicks in). I won't provide instructions on how to configure a git clean filter, as those instructions exist elsewhere.

The working script is located in my dotfiles repository, let me know if you would like to either include it in the repository as a default example, or maybe add documentation on how to accomplish this. It's not trivial, and I imagine I'm not the only one who would find this incredibly useful. I know this isn't really an "issue" per se, but I didn't know where else to suggest this.

https://github.com/knightofiam/dotfiles/blob/master/git/git-filters/clean/git-filter-project-godot-wakatime-addon.sh

Here's an example from the commit notes of just how flexible it is:

Completely filter the following git diff from project.godot:

+[editor_plugins]
+
+enabled=PoolStringArray( "res://addons/wakatime/plugin.cfg" )
+

Completely filter the following diff from project.godot:

 [editor_plugins]

-enabled=PoolStringArray( "res://addons/some-other-addon/plugin.cfg" )
+enabled=PoolStringArray( "res://addons/some-other-addon/plugin.cfg", "res://addons/wakatime/plugin.cfg" )

Partially filter the following diff in project.godot from:

 [editor_plugins]

-enabled=PoolStringArray( "res://addons/some-other-addon-1/plugin.cfg", "res://addons/wakatime/plugin.cfg" )
+enabled=PoolStringArray( "res://addons/some-other-addon-1/plugin.cfg", "res://addons/wakatime/plugin.cfg", "res://addons/some-other-addon-2/plugin.cfg" )

to:

 [editor_plugins]

-enabled=PoolStringArray( "res://addons/some-other-addon-1/plugin.cfg" )
+enabled=PoolStringArray( "res://addons/some-other-addon-1/plugin.cfg", "res://addons/some-other-addon-2/plugin.cfg" )

Partially filter the following diff in project.godot from:

 [editor_plugins]

-enabled=PoolStringArray( "res://addons/wakatime/plugin.cfg" )
+enabled=PoolStringArray( "res://addons/wakatime/plugin.cfg", "res://addons/some-other-addon-1/plugin.cfg" )

to:

+[editor_plugins]
+
+enabled=PoolStringArray( "res://addons/some-other-addon-1/plugin.cfg" )
+

There's additional files for configuring a global clean filter, so that no project-level .gitattributes or .git/config or .gitignore has to be added or modified. It can all be done at a global level, once for all local git projects. You can see the other files for this in the commit here:

knightofiam/dotfiles@f5a1659

P.S. It uses GNU sed & GNU grep, which works on macOS & Linux, & I know there's some port for WIndows but that's untested, but in any case, I'm sure the script can easily be adapted for that environment as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant