unjs/giget

Get git commit id from tarball

Opened this issue · 3 comments

Describe the feature

I'd like to inform the user what is the git commit hash that is being downloaded when a branch or tag is passed.

Since giget doesn't depend on git, we'd need to assume that the tarball downloaded from the providers are generated using git archive.

If that's the case, the commit id could be retrieved from the tarball.

Example:

wget https://codeload.github.com/unjs/giget/tar.gz/tags/v1.1.2
zcat v1.1.2 | git get-tar-commit-id
8ddd2a4eb6045710c1bac9761e97152cf6af4b8a

8ddd2a4

Additional information

  • Would you be willing to help implement this feature?
pi0 commented

Interesting idea. I think somehow we should extract such metadata from tar archive. We use node-tar internally might be a way to retrieve commit id.

pi0 commented

Thanks. Seems reading is not that hard even if node-tar does not supports, we can easily find comment header: (update we can: https://github.com/isaacs/node-tar#class-tarpax)

> head release.tar
pax_global_header00006660000000000000000000000064143737264400014524gustar00rootroot0000000000000052 comment=8ddd2a4eb6045710c1bac9761e97152cf6af4b8a