Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
疯人忠
Cvat
提交
690ecf9c
C
Cvat
项目概览
疯人忠
/
Cvat
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
Cvat
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
690ecf9c
编写于
11月 08, 2019
作者:
Z
zhiltsov-max
提交者:
Nikita Manovich
11月 08, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add support for ip git repo urls (#827)
* Add support for ip v4 git repo urls * Add tests for git urls
上级
befe5efb
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
66 addition
and
8 deletion
+66
-8
.travis.yml
.travis.yml
+1
-1
.vscode/launch.json
.vscode/launch.json
+1
-1
CHANGELOG.md
CHANGELOG.md
+1
-0
cvat/apps/git/git.py
cvat/apps/git/git.py
+11
-6
cvat/apps/git/tests.py
cvat/apps/git/tests.py
+52
-0
未找到文件。
.travis.yml
浏览文件 @
690ecf9c
...
...
@@ -12,5 +12,5 @@ before_script:
-
docker-compose -f docker-compose.yml -f docker-compose.ci.yml up --build -d
script
:
-
docker exec -it cvat /bin/bash -c 'python3 manage.py test cvat/apps
/engine
utils/cli'
-
docker exec -it cvat /bin/bash -c 'python3 manage.py test cvat/apps utils/cli'
-
docker exec -it cvat /bin/bash -c 'cd cvat-core && npm install && npm run test && npm run coveralls'
.vscode/launch.json
浏览文件 @
690ecf9c
...
...
@@ -134,7 +134,7 @@
"test"
,
"--settings"
,
"cvat.settings.testing"
,
"cvat/apps
/engine
"
,
"cvat/apps"
,
"utils/cli"
],
"django"
:
true
,
...
...
CHANGELOG.md
浏览文件 @
690ecf9c
...
...
@@ -25,6 +25,7 @@ https://github.com/opencv/cvat/issues/750).
### Fixed
-
[
Mask problem on coco json style
](
https://github.com/opencv/cvat/issues/718
)
-
[
Exception in Git plugin
](
https://github.com/opencv/cvat/issues/826
)
### Security
-
...
...
cvat/apps/git/git.py
浏览文件 @
690ecf9c
...
...
@@ -76,8 +76,13 @@ class Git:
# HTTP/HTTPS: [http://]github.com/proj/repos[.git]
def
_parse_url
(
self
):
try
:
http_pattern
=
"([https|http]+)*[://]*([a-zA-Z0-9._-]+.[a-zA-Z]+)/([a-zA-Z0-9._-]+)/([a-zA-Z0-9._-]+)"
ssh_pattern
=
"([a-zA-Z0-9._-]+)@([a-zA-Z0-9._-]+):([a-zA-Z0-9._-]+)/([a-zA-Z0-9._-]+)"
# Almost STD66 (RFC3986), but schema can include a leading digit
# Reference on URL formats accepted by Git:
# https://github.com/git/git/blob/77bd3ea9f54f1584147b594abc04c26ca516d987/url.c
host_pattern
=
r
"((?:(?:(?:\d{1,3}\.){3}\d{1,3})|(?:[a-zA-Z0-9._-]+.[a-zA-Z]+))(?::\d+)?)"
http_pattern
=
r
"(?:http[s]?://)?"
+
host_pattern
+
r
"((?:/[a-zA-Z0-9._-]+){2})"
ssh_pattern
=
r
"([a-zA-Z0-9._-]+)@"
+
host_pattern
+
r
":([a-zA-Z0-9._-]+)/([a-zA-Z0-9._-]+)"
http_match
=
re
.
match
(
http_pattern
,
self
.
_url
)
ssh_match
=
re
.
match
(
ssh_pattern
,
self
.
_url
)
...
...
@@ -87,21 +92,21 @@ class Git:
repos
=
None
if
http_match
:
host
=
http_match
.
group
(
2
)
repos
=
"{}/{}"
.
format
(
http_match
.
group
(
3
),
http_match
.
group
(
4
))
host
=
http_match
.
group
(
1
)
repos
=
http_match
.
group
(
2
)[
1
:]
elif
ssh_match
:
user
=
ssh_match
.
group
(
1
)
host
=
ssh_match
.
group
(
2
)
repos
=
"{}/{}"
.
format
(
ssh_match
.
group
(
3
),
ssh_match
.
group
(
4
))
else
:
raise
Exception
(
"G
ot URL doesn't sutisfy for regular expressio
n"
)
raise
Exception
(
"G
it repository URL does not satisfy patter
n"
)
if
not
repos
.
endswith
(
".git"
):
repos
+=
".git"
return
user
,
host
,
repos
except
Exception
as
ex
:
slogger
.
glob
.
exception
(
'URL parsing errors occured'
,
exc_info
=
True
)
slogger
.
glob
.
exception
(
'URL parsing errors occur
r
ed'
,
exc_info
=
True
)
raise
ex
...
...
cvat/apps/git/tests.py
浏览文件 @
690ecf9c
...
...
@@ -2,6 +2,58 @@
#
# SPDX-License-Identifier: MIT
from
itertools
import
product
from
django.test
import
TestCase
# Create your tests here.
from
cvat.apps.git.git
import
Git
class
GitUrlTest
(
TestCase
):
class
FakeGit
:
def
__init__
(
self
,
url
):
self
.
_url
=
url
def
_check_correct_urls
(
self
,
samples
):
for
i
,
(
expected
,
url
)
in
enumerate
(
samples
):
git
=
GitUrlTest
.
FakeGit
(
url
)
try
:
actual
=
Git
.
_parse_url
(
git
)
self
.
assertEqual
(
expected
,
actual
,
"URL #%s: '%s'"
%
(
i
,
url
))
except
Exception
:
self
.
assertFalse
(
True
,
"URL #%s: '%s'"
%
(
i
,
url
))
def
test_correct_urls_can_be_parsed
(
self
):
hosts
=
[
'host.zone'
,
'1.2.3.4'
]
ports
=
[
''
,
':42'
]
repo_groups
=
[
'repo'
,
'r4p0'
]
repo_repos
=
[
'nkjl23'
,
'hewj'
]
git_suffixes
=
[
''
,
'.git'
]
samples
=
[]
# http samples
protocols
=
[
''
,
'http://'
,
'https://'
]
for
protocol
,
host
,
port
,
repo_group
,
repo
,
git
in
product
(
protocols
,
hosts
,
ports
,
repo_groups
,
repo_repos
,
git_suffixes
):
url
=
'{protocol}{host}{port}/{repo_group}/{repo}{git}'
.
format
(
protocol
=
protocol
,
host
=
host
,
port
=
port
,
repo_group
=
repo_group
,
repo
=
repo
,
git
=
git
)
expected
=
(
'git'
,
host
+
port
,
'%s/%s.git'
%
(
repo_group
,
repo
))
samples
.
append
((
expected
,
url
))
# git samples
users
=
[
'user'
,
'u123_.'
]
for
user
,
host
,
port
,
repo_group
,
repo
,
git
in
product
(
users
,
hosts
,
ports
,
repo_groups
,
repo_repos
,
git_suffixes
):
url
=
'{user}@{host}{port}:{repo_group}/{repo}{git}'
.
format
(
user
=
user
,
host
=
host
,
port
=
port
,
repo_group
=
repo_group
,
repo
=
repo
,
git
=
git
)
expected
=
(
user
,
host
+
port
,
'%s/%s.git'
%
(
repo_group
,
repo
))
samples
.
append
((
expected
,
url
))
self
.
_check_correct_urls
(
samples
)
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录