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
6206d301
Unverified
Commit
6206d301
authored
Nov 02, 2021
by
nateanl
Committed by
GitHub
Nov 02, 2021
Browse files
Fix bandit failure (#1960)
parent
5c8541b7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
21 deletions
+12
-21
scripts/retrieve_prs.py
scripts/retrieve_prs.py
+12
-21
No files found.
scripts/retrieve_prs.py
View file @
6206d301
import
json
import
locale
import
os
import
re
import
sys
import
argparse
...
...
@@ -20,21 +18,16 @@ Features = namedtuple(
)
def
run
(
command
):
"""Returns (return-code, stdout, stderr)"""
p
=
subprocess
.
Popen
(
command
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
shell
=
True
)
output
,
err
=
p
.
communicate
()
rc
=
p
.
returncode
enc
=
locale
.
getpreferredencoding
()
output
=
output
.
decode
(
enc
)
err
=
err
.
decode
(
enc
)
return
rc
,
output
.
strip
(),
err
.
strip
()
def
_run_cmd
(
cmd
):
try
:
return
subprocess
.
check_output
(
cmd
).
strip
()
except
Exception
:
return
None
def
commit_title
(
commit_hash
):
cmd
=
f
"git log -n 1 --pretty=format:%s
{
commit_hash
}
"
ret
,
out
,
err
=
run
(
cmd
)
return
out
if
ret
==
0
else
None
cmd
=
[
'git'
,
'log'
,
'-n'
,
'1'
,
'--pretty=format:%s'
,
f
'
{
commit_hash
}
'
]
return
_run_cmd
(
cmd
)
def
parse_pr_number
(
commit_hash
,
title
):
...
...
@@ -102,15 +95,13 @@ def get_features(commit_hash):
def
get_commits_between
(
base_version
,
new_version
):
cmd
=
f
"git merge-base
{
base_version
}
{
new_version
}
"
rc
,
merge_base
,
err
=
run
(
cmd
)
assert
rc
==
0
,
err
cmd
=
[
'git'
,
'merge-base'
,
f
'
{
base_version
}
'
,
f
'
{
new_version
}
'
]
merge_base
=
_run_cmd
(
cmd
)
# Returns a list of items in the form
# a7854f33 Add HuBERT model architectures (#1769)
cmd
=
f
"git log --reverse --oneline
{
merge_base
}
..
{
new_version
}
"
rc
,
commits
,
err
=
run
(
cmd
)
assert
rc
==
0
,
err
cmd
=
[
'git'
,
'log'
,
'--reverse'
,
'--oneline'
,
f
'
{
merge_base
}
..
{
new_version
}
'
]
commits
=
_run_cmd
(
cmd
)
log_lines
=
commits
.
split
(
"
\n
"
)
hashes
,
titles
=
zip
(
*
[
log_line
.
split
(
" "
,
1
)
for
log_line
in
log_lines
])
...
...
@@ -134,7 +125,7 @@ def _main(args):
if
idx
%
10
==
0
:
print
(
f
"
{
idx
}
/
{
len
(
hashes
)
}
"
)
data
=
{
commit
:
features
.
_asdict
()
for
commit
,
features
in
data
.
items
()}
data
=
{
commit
:
features
.
_asdict
()
for
commit
,
features
in
data
.
items
()}
with
open
(
args
.
file
,
"w"
)
as
f
:
json
.
dump
(
data
,
f
)
...
...
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