beltex / dshb

macOS system monitor
https://beltex.github.io/dshb
MIT License
473 stars 34 forks source link

Source code archives are missing Git submodules #29

Open beltex opened 9 years ago

beltex commented 9 years ago

This is not a dshb issue per se, but it does affect it, and so opening this up as a means to track things. Quoting https://github.com/beltex/dshb/commit/273c6a1998b7c43bbd7710adc39cd3003857881d commit message.

git-archive(1) unfortunately does not currently support including submodules in the archive it creates. This seems to be why both the "Download Zip" option on GitHub and the "Source code" tar and zip that comes with a release are missing submodules, as there using git-archive(1) underneath it seems [1]. There was a discussion a few months back on the Git mailing list about adding this functionality [2]. In the mean time we need a work around. Not only to have a real archive (the current ones won't work at all as there not real Git repos, so you can't even init the submodules), but also for folks who don't have Git or don't want to use it, they can just curl/Wget the archive and be able to build. There are various scripts out there to address this. However, they do a lot more than what we need and add yet another dependency. Thus, came up with a small shell script to do this. Added two methods of doing this to the Makefile for now.

The key problem in doing this is ignoring files in the .gitignore (which git-archive(1) does automatically). The first approach does everything locally, archiving the main repo and all the submodules individually and then putting all that together. The second approach which is simpler, but relies on remote, does a fresh clone, init's the submodules and zip's all that. This works because the repo being new is free of any files in the .gitignore (except for .git/ but thats easy to exclude via zip).

There is another option, even simpler, in which we just zip the current directory and feed in .gitignore into zip's exclude option. However, zip's exclude is a bit strange, had trouble with this approach.

[1] https://blogs.law.harvard.edu/acts/2012/10/18/github-zip-doesnt-include-submodules/#comment-975 [2] http://www.mail-archive.com/git%40vger.kernel.org/msg68665.html