Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
openEuler-Advisor
提交
43512c4b
O
openEuler-Advisor
项目概览
openeuler
/
openEuler-Advisor
通知
40
Star
4
Fork
4
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
openEuler-Advisor
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
43512c4b
编写于
9月 07, 2020
作者:
S
Shinwell Hu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
initial draft of tc_review
上级
6071b277
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
119 addition
and
6 deletion
+119
-6
advisors/gitee.py
advisors/gitee.py
+28
-6
advisors/tc_review
advisors/tc_review
+91
-0
未找到文件。
advisors/gitee.py
浏览文件 @
43512c4b
...
...
@@ -55,11 +55,12 @@ class Gitee(object):
print
(
"WARNING:"
+
str
(
err
.
headers
))
return
False
def
fork_repo
(
self
,
repo
):
def
fork_repo
(
self
,
repo
,
owner
=
"src-openeuler"
):
"""
Fork repository in gitee
"""
url
=
"https://gitee.com/api/v5/repos/src-openeuler/{repo}/forks"
.
format
(
repo
=
repo
)
url_template
=
"https://gitee.com/api/v5/repos/{owner}/{repo}/forks"
url
=
url_template
.
format
(
owner
=
owner
,
repo
=
repo
)
values
=
{}
values
[
"access_token"
]
=
self
.
token
[
"access_token"
]
#headers["User-Agent"] = "curl/7.66.0"
...
...
@@ -79,14 +80,15 @@ class Gitee(object):
Yours openEuler-Advisor."""
self
.
post_issue
(
repo
,
title
,
body
)
def
get_reviewers
(
self
,
repo
):
def
get_reviewers
(
self
,
repo
,
owner
=
"src-openeuler"
):
"""
Get reviewers of pkg
"""
url
=
"https://gitee.com/api/v5/repos/src-openeuler/{pkg}/collaborators"
.
format
(
pkg
=
repo
)
url_template
=
"https://gitee.com/api/v5/repos/{owner}/{pkg}/collaborators"
url
=
url_template
.
format
(
owner
=
owner
,
pkg
=
repo
)
return
self
.
get_gitee
(
url
)
def
create_pr
(
self
,
head
,
repo
,
version
,
branch
):
def
create_pr
(
self
,
head
,
repo
,
version
,
branch
,
owner
=
"src-openeuler"
):
"""
Create PR in gitee
"""
...
...
@@ -95,7 +97,8 @@ class Gitee(object):
if
reviewer_info
:
reviewer_list
=
json
.
loads
(
reviewer_info
)
assignees
=
","
.
join
(
reviewer
[
"login"
]
for
reviewer
in
reviewer_list
)
url
=
"https://gitee.com/api/v5/repos/src-openeuler/{pkg}/pulls"
.
format
(
pkg
=
repo
)
url_template
=
"https://gitee.com/api/v5/repos/{owner}/{pkg}/pulls"
url
=
url_template
.
format
(
owner
=
owner
,
pkg
=
repo
)
values
=
{}
values
[
"access_token"
]
=
self
.
token
[
"access_token"
]
values
[
"title"
]
=
"Upgrade {pkg} to {ver}"
.
format
(
pkg
=
repo
,
ver
=
version
)
...
...
@@ -109,6 +112,17 @@ class Gitee(object):
Yours openEuler-Advisor."""
return
self
.
post_gitee
(
url
,
values
)
def
create_pr_comment
(
self
,
repo
,
number
,
body
,
owner
=
"src-openeuler"
):
"""
Post comment to the given specific PR
"""
url_template
=
"https://gitee.com/api/v5/repos/{owner}/{repo}/pulls/{number}/comments"
url
=
url_template
.
format
(
owner
=
owner
,
repo
=
repo
,
number
=
number
)
values
=
{}
values
[
"access_token"
]
=
self
.
token
[
"access_token"
]
values
[
"body"
]
=
body
return
self
.
post_gitee
(
url
,
values
)
def
get_gitee
(
self
,
url
,
headers
=
None
):
"""
GET from gitee api
...
...
@@ -123,6 +137,14 @@ class Gitee(object):
except
urllib
.
error
.
HTTPError
:
return
None
def
get_pr
(
self
,
repo
,
num
,
owner
=
"src-openeuler"
):
"""
Get detailed information of the given specific PR
"""
url_template
=
"https://gitee.com/api/v5/repos/{owner}/{repo}/pulls/{number}"
url
=
url_template
.
format
(
owner
=
owner
,
repo
=
repo
,
number
=
num
)
return
self
.
get_gitee_json
(
url
)
def
get_gitee_json
(
self
,
url
):
"""
Get and load gitee json response
...
...
advisors/tc_review
0 → 100755
浏览文件 @
43512c4b
#!/usr/bin/python3
#******************************************************************************
# Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.
# licensed under the Mulan PSL v2.
# You can use this software according to the terms and conditions of the Mulan PSL v2.
# You may obtain a copy of Mulan PSL v2 at:
# http://license.coscl.org.cn/MulanPSL2
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
# PURPOSE.
# See the Mulan PSL v2 for more details.
# ******************************************************************************/
"""
Review tool for openEuler submission
"""
import
os
import
argparse
import
subprocess
import
gitee
def
check_repository_changes
():
lst_files
=
subprocess
.
getoutput
(
"git diff --name-only remotes/origin/master.."
)
for
item
in
lst_files
.
splitlines
():
if
item
.
startswith
(
"sig/sigs.yaml"
):
return
True
else
:
return
False
def
check_maintainer_changes
():
"""
return a list of SIGs with changed maintainer
"""
sigs
=
[]
lst_files
=
subprocess
.
getoutput
(
"git diff --name-only remotes/origin/master.."
)
for
item
in
lst_files
.
splitlines
():
if
item
.
startswith
(
"sig"
)
and
item
.
endswith
(
"OWNERS"
):
sigs
.
append
(
item
.
split
(
"/"
)[
1
])
return
sigs
def
review
(
pr
):
review_body
=
""
review_body
+=
"[ ] Is the Title of this PR self-explain ?
\n
"
review_body
+=
"[ ] Is the description of this PR detailed ?
\n
"
review_body
+=
"[ ] Does the PR match the code changes ?
\n
"
sigs
=
check_maintainer_changes
()
if
sigs
:
review_body
+=
"Changes in maintainship detected:
\n
"
review_body
+=
"[ ] If new maintainer added, are there any assertion on his/her capability on maintainship ?
\n
"
for
sig
in
sigs
:
review_body
+=
"[ ] Do other maintainers of {sig} also agree to add/remove his/her as a maintainer ?
\n
"
.
format
(
sig
=
sig
)
if
check_repository_changes
():
review_body
+=
"Changes in sigs.yaml detected:
\n
"
review_body
+=
"[ ] Are all changed repositories managed by proper SIG ?
\n
"
review_body
+=
"[ ] Do all affected SIG maintainers agree the change ?
\n
"
return
review_body
def
main
():
"""
Main entrance of the functionality
"""
pars
=
argparse
.
ArgumentParser
()
pars
.
add_argument
(
"-p"
,
"--pull"
,
type
=
str
,
help
=
"Number ID of Pull Request"
,
required
=
True
)
pars
.
add_argument
(
"-r"
,
"--reuse"
,
help
=
"Reuse current local git dirctory"
,
action
=
"store_true"
)
args
=
pars
.
parse_args
()
user_gitee
=
gitee
.
Gitee
()
gitee_url
=
"git@gitee.com:openeuler/community"
if
not
args
.
reuse
:
subprocess
.
call
([
"git"
,
"clone"
,
gitee_url
])
os
.
chdir
(
args
.
repo
.
split
(
'/'
)[
1
])
subprocess
.
call
([
"git"
,
"fetch"
,
gitee_url
,
"pull/{n}/head:pr_{n}"
.
format
(
n
=
args
.
pull
)])
print
(
"You are reviewing pull {n}"
.
format
(
n
=
args
.
pull
))
subprocess
.
call
([
"git"
,
"checkout"
,
"pr_{n}"
.
format
(
n
=
args
.
pull
)])
subprocess
.
call
([
"git"
,
"merge"
,
"--no-edit"
,
"master"
])
pr
=
user_gitee
.
get_pr
(
"community"
,
args
.
pull
,
"openeuler"
)
review_comment
=
review
(
pr
)
user_gitee
.
create_pr_comment
(
"community"
,
args
.
pull
,
review_comment
,
"openeuler"
)
if
__name__
==
"__main__"
:
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录