It looks promising but needs a little tweaks at best.
Your code makes the button visible when the current path ends with ".git", which is incorrect.
The button needs to be visible when the current path + "./git" exists, as the following figure shows.
The basic requirement is that assume the current folder is "C:/a/b/c", the button should be visible if "C:/a/b/c/.git" exists.
The bonus requirement is that assume the current folder is "C:/a/b/c", the button should be visible if any of "C:/a/b/.git", "C:/a/.git", "C:/.git" exists.
I see... Sorry, I think we can only examine the current path, not check for any subfolders. The next version might support this, I remember reading about plans to enhance the modifier system.