Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
Torchaudio
Commits
42e67972
Unverified
Commit
42e67972
authored
Nov 02, 2021
by
nateanl
Committed by
GitHub
Nov 02, 2021
Browse files
Refactor collecting-PR script for release note (#1951)
parent
6206d301
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
16 deletions
+17
-16
tools/retrieve_prs.py
tools/retrieve_prs.py
+17
-16
No files found.
script
s/retrieve_prs.py
→
tool
s/retrieve_prs.py
View file @
42e67972
"""Collect the PRs between two specified tags or commits and
output the commit titles, PR numbers, and labels in a json file.
Usage: python tools/release_notes/retrieve_prs.py tags/v0.10.0
\
18685a517ae68353b05b9a0ede5343df31525c76 --file data.json
"""
import
argparse
import
json
import
json
import
re
import
re
import
sys
import
argparse
import
subprocess
import
subprocess
from
collections
import
namedtuple
from
collections
import
namedtuple
from
os.path
import
expanduser
from
os.path
import
expanduser
import
requests
import
requests
Features
=
namedtuple
(
Features
=
namedtuple
(
"Features"
,
"Features"
,
[
[
...
@@ -19,10 +24,7 @@ Features = namedtuple(
...
@@ -19,10 +24,7 @@ Features = namedtuple(
def
_run_cmd
(
cmd
):
def
_run_cmd
(
cmd
):
try
:
return
subprocess
.
check_output
(
cmd
).
decode
(
'utf-8'
).
strip
()
return
subprocess
.
check_output
(
cmd
).
strip
()
except
Exception
:
return
None
def
commit_title
(
commit_hash
):
def
commit_title
(
commit_hash
):
...
@@ -57,11 +59,9 @@ headers = {"Authorization": f"token {token}"}
...
@@ -57,11 +59,9 @@ headers = {"Authorization": f"token {token}"}
def
run_query
(
query
):
def
run_query
(
query
):
request
=
requests
.
post
(
"https://api.github.com/graphql"
,
json
=
{
"query"
:
query
},
headers
=
headers
)
response
=
requests
.
post
(
"https://api.github.com/graphql"
,
json
=
{
"query"
:
query
},
headers
=
headers
)
if
request
.
status_code
==
200
:
response
.
raise_for_status
()
return
request
.
json
()
return
response
.
json
()
else
:
raise
Exception
(
"Query failed to run by returning code of {}. {}"
.
format
(
request
.
status_code
,
query
))
def
gh_labels
(
pr_number
):
def
gh_labels
(
pr_number
):
...
@@ -108,8 +108,11 @@ def get_commits_between(base_version, new_version):
...
@@ -108,8 +108,11 @@ def get_commits_between(base_version, new_version):
return
hashes
,
titles
return
hashes
,
titles
def
_parse_args
(
args
):
def
_parse_args
(
args
=
None
):
parser
=
argparse
.
ArgumentParser
()
parser
=
argparse
.
ArgumentParser
(
description
=
__doc__
,
formatter_class
=
argparse
.
RawTextHelpFormatter
,
)
parser
.
add_argument
(
"base_version"
,
type
=
str
,
help
=
"starting tag or commit (exclusive)"
)
parser
.
add_argument
(
"base_version"
,
type
=
str
,
help
=
"starting tag or commit (exclusive)"
)
parser
.
add_argument
(
"new_version"
,
type
=
str
,
help
=
"final tag or commit (inclusive)"
)
parser
.
add_argument
(
"new_version"
,
type
=
str
,
help
=
"final tag or commit (inclusive)"
)
parser
.
add_argument
(
"--file"
,
type
=
str
,
default
=
"data.json"
,
help
=
"output json file"
)
parser
.
add_argument
(
"--file"
,
type
=
str
,
default
=
"data.json"
,
help
=
"output json file"
)
...
@@ -131,6 +134,4 @@ def _main(args):
...
@@ -131,6 +134,4 @@ def _main(args):
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
# Usage: python scripts/release_notes/retrieve_prs.py tags/v0.10.0 \
_main
(
_parse_args
())
# 18685a517ae68353b05b9a0ede5343df31525c76 --file data.json
_main
(
_parse_args
(
sys
.
argv
[
1
:]))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment