`pub get` should more gracefully handle non-git dirs in the git pub cache
I ran into an issue today where I couldn't run a pub get (or upgrade) in any flutter_web project (even fresh ones).
The error I was getting was this:
fatal: not a git repository (or any parent up to mount point /usr/local)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
This was quite cryptic, and didn't indicate even which package dependency had failed. I later ran with -v and got some better information, it was trying to run a git fetch inside of the pub cache (specifically, at ~/.pub-cache/git/cache/flutter_web-c860685d0da1a4da933bd4d77e11442441614877), which was a completely empty directory.
I am not sure exactly how an empty directory got added there, presumably a previous git clone or something had failed.
Deleting the directory solved my problems, but it was difficult to resolve.
I think it would be reasonable to handle this scenario explicitly, by handling the not a git repository error and deleting the entire directory from the pub cache and retrying.
This seems still relevant