Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
riscv-gcc-1
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
riscv-gcc-1
Commits
ce84ada3
Commit
ce84ada3
authored
Jul 28, 2016
by
Martin Liska
Committed by
Martin Liska
Jul 28, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add mark_spam.py script
* mark_spam.py: New file. From-SVN: r238809
parent
e5f5bf35
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
90 additions
and
0 deletions
+90
-0
contrib/ChangeLog
+4
-0
contrib/mark_spam.py
+86
-0
No files found.
contrib/ChangeLog
View file @
ce84ada3
2016
-
07
-
28
Martin
Liska
<
mliska
@suse
.
cz
>
*
mark_spam
.
py
:
New
file
.
2016
-
07
-
21
Martin
Liska
<
mliska
@suse
.
cz
>
2016
-
07
-
21
Martin
Liska
<
mliska
@suse
.
cz
>
*
analyze_brprob
.
py
:
If
there
'
s
no
loop
,
do
not
calculate
*
analyze_brprob
.
py
:
If
there
'
s
no
loop
,
do
not
calculate
...
...
contrib/mark_spam.py
0 → 100644
View file @
ce84ada3
#!/usr/bin/env python3
#
# Script to mark bunch of PRs as spam
#
# This file is part of GCC.
#
# GCC is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 3, or (at your option) any later
# version.
#
# GCC is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with GCC; see the file COPYING3. If not see
# <http://www.gnu.org/licenses/>. */
#
#
#
import
requests
import
json
import
argparse
base_url
=
'https://gcc.gnu.org/bugzilla/rest.cgi/'
def
mark_as_spam
(
id
,
api_key
,
verbose
):
print
(
'Marking as spam: PR
%
d'
%
id
)
# 1) get bug info to find 'cc'
u
=
base_url
+
'bug/'
+
str
(
id
)
r
=
requests
.
get
(
u
)
response
=
json
.
loads
(
r
.
text
)
# 2) mark the bug as spam
cc_list
=
response
[
'bugs'
][
0
][
'cc'
]
data
=
{
'status'
:
'RESOLVED'
,
'resolution'
:
'INVALID'
,
'summary'
:
'spam'
,
'ids'
:
[
id
],
'api_key'
:
api_key
,
'comment'
:
{
'comment'
:
'spam'
},
'product'
:
'gcc'
,
'component'
:
'spam'
,
'version'
:
'unknown'
,
'cc'
:
{
'remove'
:
cc_list
},
'priority'
:
'P5'
,
'severity'
:
'trivial'
,
'assigned_to'
:
'unassigned@gcc.gnu.org'
}
r
=
requests
.
put
(
u
,
json
=
data
)
if
verbose
:
print
(
r
)
print
(
r
.
text
)
# 3) mark the first comment as spam
r
=
requests
.
get
(
u
+
'/comment'
)
response
=
json
.
loads
(
r
.
text
)
comment_id
=
response
[
'bugs'
][
str
(
id
)][
'comments'
][
0
][
'id'
]
u2
=
'
%
sbug/comment/
%
d/tags'
%
(
base_url
,
comment_id
)
r
=
requests
.
put
(
u2
,
json
=
{
'comment_id'
:
comment_id
,
'add'
:
[
'spam'
],
'api_key'
:
api_key
})
if
verbose
:
print
(
r
)
print
(
r
.
text
)
parser
=
argparse
.
ArgumentParser
(
description
=
'Mark Bugzilla issues as spam.'
)
parser
.
add_argument
(
'api_key'
,
help
=
'API key'
)
parser
.
add_argument
(
'range'
,
help
=
'Range of IDs, e.g. 10-23,24,25,27'
)
parser
.
add_argument
(
'--verbose'
,
action
=
'store_true'
,
help
=
'Verbose logging'
)
args
=
parser
.
parse_args
()
chunks
=
args
.
range
.
split
(
','
)
for
c
in
chunks
:
parts
=
list
(
map
(
lambda
x
:
int
(
x
),
c
.
split
(
'-'
)))
if
len
(
parts
)
==
1
:
r
=
[
parts
[
0
]]
else
:
r
=
range
(
parts
[
0
],
parts
[
1
]
+
1
)
for
id
in
r
:
mark_as_spam
(
id
,
args
.
api_key
,
args
.
verbose
)
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