由于各种原因,GitHub 用户可以从任何一个 repo 的 remote 通过类似 git fetch origin [COMMIT-HASH] 的方式获取其 fork 树上的任何一个 repo 的 commit。也就是说,在 fork repo 中提交的内容可以通过在原 repo 的 remote 上进行 fetch 来获取。又由于用户不能删除 Pull requests,一旦内容被以 Pull requests 的形式提交,Pull requests 中的 commit 就会一直保留。通过这样的方法,用户 Stephen304 将一份 10 月 23 日的 youtube-dl 源码树放在了 github/dmca 上。
用户可以通过以下方式获取这段源码树:
git clone https://github.com/github/dmca.git && cd dmca
git fetch origin 416da574ec0df3388f652e44f7fe71b1e3a4701f
git checkout 416da574ec0df3388f652e44f7fe71b1e3a4701f
src: https://news.ycombinator.com/item?id=24882921
seealso: https://github.com/github/dmca/pull/8142
seealso: https://github.com/github/dmca/tree/416da574ec0df3388f652e44f7fe71b1e3a4701f
PKGBUILD
pkgname=youtube-dl-git
_gitname="youtube-dl"
pkgver=416da574e
pkgrel=1
pkgdesc="A small command-line program to download videos from YouTube.com and a few more sites (git version)"
arch=('any')
url="http://ytdl-org.github.io/youtube-dl/"
license=('custom')
depends=('python' 'python-setuptools')
makedepends=('git' 'pandoc')
optdepends=('ffmpeg: for video post-processing'
'rtmpdump: for rtmp streams support'
'atomicparsley: for embedding thumbnails into m4a files'
'phantomjs: for openload support')
provides=("youtube-dl")
conflicts=("youtube-dl")
source=('youtube-dl::git+https://github.com/github/dmca.git#commit=416da574ec0df3388f652e44f7fe71b1e3a4701f')
md5sums=('SKIP')
pkgver() {
cd $_gitname
printf "%s" "$(git rev-parse --short HEAD)"
}
prepare() {
cd $_gitname
sed -i 's|etc/bash_completion.d|share/bash-completion/completions|' setup.py
sed -i 's|etc/fish/completions|share/fish/completions|' setup.py
}
build() {
cd $_gitname
make pypi-files zsh-completion
}
package() {
cd $_gitname
python setup.py install --root="${pkgdir}/" --optimize=1
mv "${pkgdir}/usr/share/bash-completion/completions/youtube-dl.bash-completion" \
"${pkgdir}/usr/share/bash-completion/completions/youtube-dl"
install -Dm644 youtube-dl.zsh "${pkgdir}/usr/share/zsh/site-functions/_youtube-dl"
install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}