Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
cf7b6a4f
C
ClickHouse
项目概览
2dot5
/
ClickHouse
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
ClickHouse
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
cf7b6a4f
编写于
3月 17, 2020
作者:
N
Nikolai Kochetov
提交者:
GitHub
3月 17, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #9685 from ClickHouse/backport-script-fixes
Update script for backporting.
上级
1580ffb5
1edf735e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
46 addition
and
19 deletion
+46
-19
utils/github/__main__.py
utils/github/__main__.py
+3
-1
utils/github/parser.py
utils/github/parser.py
+17
-1
utils/github/query.py
utils/github/query.py
+26
-17
未找到文件。
utils/github/__main__.py
浏览文件 @
cf7b6a4f
...
...
@@ -49,7 +49,7 @@ parser.add_argument('--token', type=str, required=True,
help
=
'token for Github access'
)
parser
.
add_argument
(
'--login'
,
type
=
str
,
help
=
'filter authorship by login'
)
parser
.
add_argument
(
'--auto-label'
,
action
=
'store_true'
,
dest
=
'autolabel'
,
parser
.
add_argument
(
'--auto-label'
,
action
=
'store_true'
,
dest
=
'autolabel'
,
default
=
True
,
help
=
'try to automatically parse PR description and put labels'
)
args
=
parser
.
parse_args
()
...
...
@@ -80,6 +80,8 @@ for i in reversed(range(len(stables))):
members
=
set
(
github
.
get_members
(
"ClickHouse"
,
"ClickHouse"
))
def
print_responsible
(
pull_request
):
if
"author"
not
in
pull_request
or
pull_request
[
"author"
]
is
None
:
return
"No author"
if
pull_request
[
"author"
][
"login"
]
in
members
:
return
colored
(
pull_request
[
"author"
][
"login"
],
'green'
)
elif
pull_request
[
"mergedBy"
][
"login"
]
in
members
:
...
...
utils/github/parser.py
浏览文件 @
cf7b6a4f
...
...
@@ -10,6 +10,10 @@ class Description:
'Performance Improvement'
:
'pr-performance'
,
# 'Backward Incompatible Change': doesn't match anything
'Build/Testing/Packaging Improvement'
:
'pr-build'
,
'Non-significant (changelog entry is not needed)'
:
'pr-non-significant'
,
'Non-significant (changelog entry is not required)'
:
'pr-non-significant'
,
'Non-significant'
:
'pr-non-significant'
,
'Documentation (changelog entry is not required)'
:
'pr-documentation'
,
# 'Other': doesn't match anything
}
...
...
@@ -37,8 +41,20 @@ class Description:
if
stripped
==
'I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en'
:
self
.
legal
=
True
if
stripped
==
'Category (leave one):'
:
category_headers
=
(
'Category (leave one):'
,
'Changelog category (leave one):'
,
'Changelog category:'
,
'Category:'
)
if
stripped
in
category_headers
:
next_category
=
True
if
category
in
Description
.
MAP_CATEGORY_TO_LABEL
:
self
.
label_name
=
Description
.
MAP_CATEGORY_TO_LABEL
[
category
]
else
:
if
not
category
:
print
(
'Cannot find category in pr description'
)
else
:
print
(
'Unknown category: '
+
category
)
utils/github/query.py
浏览文件 @
cf7b6a4f
# -*- coding: utf-8 -*-
import
requests
import
time
class
Query
:
...
...
@@ -394,20 +395,28 @@ class Query:
}}
}}
'''
request
=
requests_retry_session
().
post
(
'https://api.github.com/graphql'
,
json
=
{
'query'
:
query
},
headers
=
headers
)
if
request
.
status_code
==
200
:
result
=
request
.
json
()
if
'errors'
in
result
:
raise
Exception
(
f
'Errors occured:
{
result
[
"errors"
]
}
'
)
if
not
is_mutation
:
import
inspect
caller
=
inspect
.
getouterframes
(
inspect
.
currentframe
(),
2
)[
1
][
3
]
if
caller
not
in
self
.
api_costs
.
keys
():
self
.
api_costs
[
caller
]
=
0
self
.
api_costs
[
caller
]
+=
result
[
'data'
][
'rateLimit'
][
'cost'
]
return
result
[
'data'
]
else
:
import
json
raise
Exception
(
f
'Query failed with code
{
request
.
status_code
}
:
\n
{
json
.
dumps
(
request
.
json
(),
indent
=
4
)
}
'
)
while
True
:
request
=
requests_retry_session
().
post
(
'https://api.github.com/graphql'
,
json
=
{
'query'
:
query
},
headers
=
headers
)
if
request
.
status_code
==
200
:
result
=
request
.
json
()
if
'errors'
in
result
:
raise
Exception
(
f
'Errors occured:
{
result
[
"errors"
]
}
'
)
if
not
is_mutation
:
import
inspect
caller
=
inspect
.
getouterframes
(
inspect
.
currentframe
(),
2
)[
1
][
3
]
if
caller
not
in
self
.
api_costs
.
keys
():
self
.
api_costs
[
caller
]
=
0
self
.
api_costs
[
caller
]
+=
result
[
'data'
][
'rateLimit'
][
'cost'
]
return
result
[
'data'
]
else
:
import
json
resp
=
request
.
json
()
if
resp
and
len
(
resp
)
>
0
and
resp
[
0
]
and
'type'
in
resp
[
0
]
and
resp
[
0
][
'type'
]
==
'RATE_LIMITED'
:
print
(
"API rate limit exceeded. Waiting for 1 second."
)
time
.
sleep
(
1
)
continue
raise
Exception
(
f
'Query failed with code
{
request
.
status_code
}
:
\n
{
json
.
dumps
(
resp
,
indent
=
4
)
}
'
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录