Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
镜像
Python_Packaging_Authority
pip
提交
632896d7
P
pip
项目概览
镜像
/
Python_Packaging_Authority
/
pip
12 个月 前同步成功
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
pip
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
632896d7
编写于
1月 12, 2019
作者:
C
Chris Jerdonek
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move make_vcs_requirement_url() to vcs/__init__.py.
上级
f4f447cc
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
44 addition
and
46 deletion
+44
-46
src/pip/_internal/utils/misc.py
src/pip/_internal/utils/misc.py
+0
-16
src/pip/_internal/vcs/__init__.py
src/pip/_internal/vcs/__init__.py
+18
-2
src/pip/_internal/vcs/bazaar.py
src/pip/_internal/vcs/bazaar.py
+1
-4
tests/unit/test_utils.py
tests/unit/test_utils.py
+3
-23
tests/unit/test_vcs.py
tests/unit/test_vcs.py
+22
-1
未找到文件。
src/pip/_internal/utils/misc.py
浏览文件 @
632896d7
...
...
@@ -899,22 +899,6 @@ def enum(*sequential, **named):
return
type
(
'Enum'
,
(),
enums
)
def
make_vcs_requirement_url
(
repo_url
,
rev
,
project_name
,
subdir
=
None
):
"""
Return the URL for a VCS requirement.
Args:
repo_url: the remote VCS url, with any needed VCS prefix (e.g. "git+").
project_name: the (unescaped) project name.
"""
egg_project_name
=
pkg_resources
.
to_filename
(
project_name
)
req
=
'{}@{}#egg={}'
.
format
(
repo_url
,
rev
,
egg_project_name
)
if
subdir
:
req
+=
'&subdirectory={}'
.
format
(
subdir
)
return
req
def
split_auth_from_netloc
(
netloc
):
"""
Parse out and remove the auth information from a netloc.
...
...
src/pip/_internal/vcs/__init__.py
浏览文件 @
632896d7
...
...
@@ -7,12 +7,12 @@ import os
import
shutil
import
sys
from
pip._vendor
import
pkg_resources
from
pip._vendor.six.moves.urllib
import
parse
as
urllib_parse
from
pip._internal.exceptions
import
BadCommand
from
pip._internal.utils.misc
import
(
ask_path_exists
,
backup_dir
,
call_subprocess
,
display_path
,
make_vcs_requirement_url
,
rmtree
,
ask_path_exists
,
backup_dir
,
call_subprocess
,
display_path
,
rmtree
,
)
from
pip._internal.utils.typing
import
MYPY_CHECK_RUNNING
...
...
@@ -30,6 +30,22 @@ __all__ = ['vcs']
logger
=
logging
.
getLogger
(
__name__
)
def
make_vcs_requirement_url
(
repo_url
,
rev
,
project_name
,
subdir
=
None
):
"""
Return the URL for a VCS requirement.
Args:
repo_url: the remote VCS url, with any needed VCS prefix (e.g. "git+").
project_name: the (unescaped) project name.
"""
egg_project_name
=
pkg_resources
.
to_filename
(
project_name
)
req
=
'{}@{}#egg={}'
.
format
(
repo_url
,
rev
,
egg_project_name
)
if
subdir
:
req
+=
'&subdirectory={}'
.
format
(
subdir
)
return
req
class
RemoteNotFoundError
(
Exception
):
pass
...
...
src/pip/_internal/vcs/bazaar.py
浏览文件 @
632896d7
...
...
@@ -6,10 +6,7 @@ import os
from
pip._vendor.six.moves.urllib
import
parse
as
urllib_parse
from
pip._internal.download
import
path_to_url
from
pip._internal.utils.misc
import
(
display_path
,
make_vcs_requirement_url
,
rmtree
,
)
from
pip._internal.utils.temp_dir
import
TempDirectory
from
pip._internal.utils.misc
import
display_path
,
rmtree
from
pip._internal.vcs
import
VersionControl
,
vcs
logger
=
logging
.
getLogger
(
__name__
)
...
...
tests/unit/test_utils.py
浏览文件 @
632896d7
...
...
@@ -25,10 +25,9 @@ from pip._internal.utils.glibc import check_glibc_version
from
pip._internal.utils.hashes
import
Hashes
,
MissingHashes
from
pip._internal.utils.misc
import
(
call_subprocess
,
egg_link_path
,
ensure_dir
,
format_command_args
,
get_installed_distributions
,
get_prog
,
make_vcs_requirement_url
,
normalize_path
,
redact_netloc
,
redact_password_from_url
,
remove_auth_from_url
,
rmtree
,
split_auth_from_netloc
,
untar_file
,
unzip_file
,
get_installed_distributions
,
get_prog
,
normalize_path
,
redact_netloc
,
redact_password_from_url
,
remove_auth_from_url
,
rmtree
,
split_auth_from_netloc
,
untar_file
,
unzip_file
,
)
from
pip._internal.utils.packaging
import
check_dist_requires_python
from
pip._internal.utils.temp_dir
import
AdjacentTempDirectory
,
TempDirectory
...
...
@@ -758,25 +757,6 @@ def test_call_subprocess_closes_stdin():
)
@
pytest
.
mark
.
parametrize
(
'args, expected'
,
[
# Test without subdir.
((
'git+https://example.com/pkg'
,
'dev'
,
'myproj'
),
'git+https://example.com/pkg@dev#egg=myproj'
),
# Test with subdir.
((
'git+https://example.com/pkg'
,
'dev'
,
'myproj'
,
'sub/dir'
),
'git+https://example.com/pkg@dev#egg=myproj&subdirectory=sub/dir'
),
# Test with None subdir.
((
'git+https://example.com/pkg'
,
'dev'
,
'myproj'
,
None
),
'git+https://example.com/pkg@dev#egg=myproj'
),
# Test an unescaped project name.
((
'git+https://example.com/pkg'
,
'dev'
,
'zope-interface'
),
'git+https://example.com/pkg@dev#egg=zope_interface'
),
])
def
test_make_vcs_requirement_url
(
args
,
expected
):
actual
=
make_vcs_requirement_url
(
*
args
)
assert
actual
==
expected
@
pytest
.
mark
.
parametrize
(
'netloc, expected'
,
[
# Test a basic case.
(
'example.com'
,
(
'example.com'
,
(
None
,
None
))),
...
...
tests/unit/test_vcs.py
浏览文件 @
632896d7
...
...
@@ -2,7 +2,9 @@ import pytest
from
mock
import
patch
from
pip._vendor.packaging.version
import
parse
as
parse_version
from
pip._internal.vcs
import
RevOptions
,
VersionControl
from
pip._internal.vcs
import
(
RevOptions
,
VersionControl
,
make_vcs_requirement_url
,
)
from
pip._internal.vcs.bazaar
import
Bazaar
from
pip._internal.vcs.git
import
Git
,
looks_like_hash
from
pip._internal.vcs.mercurial
import
Mercurial
...
...
@@ -15,6 +17,25 @@ else:
VERBOSE_FALSE
=
0
@
pytest
.
mark
.
parametrize
(
'args, expected'
,
[
# Test without subdir.
((
'git+https://example.com/pkg'
,
'dev'
,
'myproj'
),
'git+https://example.com/pkg@dev#egg=myproj'
),
# Test with subdir.
((
'git+https://example.com/pkg'
,
'dev'
,
'myproj'
,
'sub/dir'
),
'git+https://example.com/pkg@dev#egg=myproj&subdirectory=sub/dir'
),
# Test with None subdir.
((
'git+https://example.com/pkg'
,
'dev'
,
'myproj'
,
None
),
'git+https://example.com/pkg@dev#egg=myproj'
),
# Test an unescaped project name.
((
'git+https://example.com/pkg'
,
'dev'
,
'zope-interface'
),
'git+https://example.com/pkg@dev#egg=zope_interface'
),
])
def
test_make_vcs_requirement_url
(
args
,
expected
):
actual
=
make_vcs_requirement_url
(
*
args
)
assert
actual
==
expected
def
test_rev_options_repr
():
rev_options
=
RevOptions
(
Git
(),
'develop'
)
assert
repr
(
rev_options
)
==
"<RevOptions git: rev='develop'>"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录