2016-05-10 53 views

回答

0

你可以克隆回购,结帐你在本地所需的日期和PIP安装在开发模式:

git clone https://github.com/user/repo.git 
cd repo 
git checkout `git rev-list -n 1 --before="2016-03-03 13:37" master` 
pip install -e 
+0

作弊! :)但是,我真的要依靠指定提交sha的本机pip机制来实现+1 – user3159253

+0

。 –

+1

有什么区别?你必须克隆回购以获取日期 – maxymoo

1

好了,你可以替换<branch>与所需提交<sha-1>。我刚刚用bpython检查过它:

$ pip install --upgrade --user git+https://github.com/bpython/[email protected] 
Collecting git+https://github.com/bpython/[email protected] 
    Cloning https://github.com/bpython/bpython.git (to f2014dbae31313571cc9c26f51a14f4fda09d138) to /tmp/.private/alex/pip-tQcJmV-build 
    Could not find a tag or branch 'f2014dbae31313571cc9c26f51a14f4fda09d138', assuming commit. 
... 

另一个问题是如何获取给定日期的提交。

第一个选项是打开浏览器,找到适当的提交并手动为pip install形成正确的URL。其实我上面的例子是用这种方式。

但是你可能想自动化的东西。我会做一个给定的回购的地方浅拷贝从GitHub:

git clone --depth 10 --single-branch --branch master https://github.com/bpython/bpython.git 

(从bpython官方回购的主分支只拿10最后提交)

然后,确定什么样的commit满足日期限制:

COMMITID=$(git rev-list -n 1 --before '2016/04/07 16:36:15 2016 +0000' HEAD) 

然后,使用提交ID在pip install命令:

pip install --upgrade --user git+file:///tmp/.private/alex/[email protected]${COMMITID}