Fork me on GitHub

How to obtain source code from GitHub?

Gentoo Mono Handbook
see also git-2, git-r3, cvs-snapshot

by SHA1

When using a distributed source control system such as Git, it's important to understand that the latest check-in on the GitHub repository is not necessarily the one you want to download or sync to as it may be a different branch than the master branch.
Details about SHA1

Example

# vcs-snapshot.eclass will strip that first dir level and re-add /${P} , so default S works
# eg instead of unpacking to $WORKDIR/foo-dc8s9ee1/ , it will unpack to $WORKDIR/foo-1.2.3/ as expected
inherit vcs-snapshot

REPO_OWNER=apache
REPO_NAME=logging-log4net
EGIT_COMMIT=dbad144815221ffe4ed85efa73134583253dc75b
SRC_URI="https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/tarball/${EGIT_COMMIT} -> ${P}.tar.gz"
It should be ${P}.tar.gz, not ${CATEGORY}-${PN}-${PV}.tar.gz, to match the default value of ${S} variable

Documentation and specifications

https://docs.github.com/en/free-pro-team@latest/rest/reference/repos#download-a-repository-archive-zip
Example:
https://api.github.com/repos/apache/logging-log4net/zipball/dbad144815221ffe4ed85efa73134583253dc75b
$ wget -c https://api.github.com/repos/apache/logging-log4net/zipball/dbad144815221ffe4ed85efa73134583253dc75b
--2020-10-26 21:21:06--  https://api.github.com/repos/apache/logging-log4net/zipball/dbad144815221ffe4ed85efa73134583253dc75b
Resolving api.github.com... 140.82.121.6
Connecting to api.github.com|140.82.121.6|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://codeload.github.com/apache/logging-log4net/legacy.zip/dbad144815221ffe4ed85efa73134583253dc75b [following]
--2020-10-26 21:21:07--  https://codeload.github.com/apache/logging-log4net/legacy.zip/dbad144815221ffe4ed85efa73134583253dc75b
Resolving codeload.github.com... 140.82.121.9
Connecting to codeload.github.com|140.82.121.9|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [application/zip]
Saving to: ‘dbad144815221ffe4ed85efa73134583253dc75b’

dbad144815221ffe4ed85efa73134583253dc75b         [   <=>                                                                                         ]   1,59M  3,29MB/s    in 0,5s    

2020-10-26 21:21:08 (3,29 MB/s) - ‘dbad144815221ffe4ed85efa73134583253dc75b’ saved [1670579]


https://help.github.com/
https://developer.github.com/v3/repos/contents/#get-archive-link
github/get-archive-link.png
In github web interface it looks like this: TODO

Nodeload - https://github.com/blog/678-meet-nodeload-the-new-download-server
    any time you download a tarball or zip file of any repository branch or tag, you're going through nodeload.

looks like "ebuild ... digest" doesn't work with 302 redirect (need to be investigated deeper)

http://stackoverflow.com/questions/8377081/github-api-download-zip-or-tarball-link

by tag

github provide links for packaged sources for each commit:
for example
https://github.com/deveel/deveel-math/archive/dmath-1.5.66.tar.gz

These links can be directly used in SRC_URI variale.

import versionator
# PR Package revision, or r0 if no revision exists.
NUSPEC_VERSION=$(get_version_component_range 1-3)"${PR//r/.}"

Other

http://webapps.stackexchange.com/questions/46113/how-to-see-list-of-issues-reported-by-me-on-github
https://github.com/blog/12-tarball-downloads