Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
snippets
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Platform
Development
snippets
Commits
82923a0f
Commit
82923a0f
authored
1 year ago
by
Antoine Lambert
Browse files
Options
Downloads
Patches
Plain Diff
Add a script to extract origin URLs from a Sentry issue
parent
0d8b6877
No related branches found
Branches containing commit
Tags
swh-scrubber-20250326.1
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
anlambert/extract_origins_urls_from_sentry_issue.py
+67
-0
67 additions, 0 deletions
anlambert/extract_origins_urls_from_sentry_issue.py
with
67 additions
and
0 deletions
anlambert/extract_origins_urls_from_sentry_issue.py
0 → 100755
+
67
−
0
View file @
82923a0f
#!/usr/bin/env python3
# Copyright (C) 2023 The Software Heritage developers
# See the AUTHORS file at the top-level directory of this distribution
# License: GNU General Public License version 3, or any later version
# See top-level LICENSE file for more information
import
click
import
requests
@click.command
()
@click.option
(
"
--sentry-url
"
,
"
-u
"
,
default
=
"
https://sentry.softwareheritage.org
"
,
show_default
=
True
,
help
=
"
Sentry URL
"
,
required
=
True
,
)
@click.option
(
"
--sentry-token
"
,
"
-t
"
,
default
=
None
,
envvar
=
"
SENTRY_TOKEN
"
,
help
=
(
"
Bearer token required to communicate with Sentry API (can also be provided
"
"
in SENTRY_TOKEN environment variable)
"
),
required
=
True
,
)
@click.option
(
"
--sentry-issue-number
"
,
"
-i
"
,
help
=
"
Sentry issue number to extract origin URLs
"
,
required
=
True
,
)
def
run
(
sentry_url
,
sentry_token
,
sentry_issue_number
):
"""
Extract origin URLs from a Sentry issue related to a Software Heritage
loader and dumps them to stdout.
"""
sentry_api_base_url
=
f
"
{
sentry_url
.
rstrip
(
'
/
'
)
}
/api/0
"
sentry_issue_events_url
=
(
f
"
{
sentry_api_base_url
}
/issues/
{
sentry_issue_number
}
/events/
"
)
auth_header
=
{
"
Authorization
"
:
f
"
Bearer
{
sentry_token
}
"
}
origin_urls
=
set
()
while
True
:
response
=
requests
.
get
(
sentry_issue_events_url
,
headers
=
auth_header
)
events
=
response
.
json
()
if
not
events
:
break
for
event
in
events
:
tags
=
{
tag
[
"
key
"
]:
tag
[
"
value
"
]
for
tag
in
event
.
get
(
"
tags
"
,
[])}
if
"
swh.loader.origin_url
"
in
tags
:
origin_urls
.
add
(
tags
[
"
swh.loader.origin_url
"
])
sentry_issue_events_url
=
response
.
links
.
get
(
"
next
"
,
{}).
get
(
"
url
"
)
for
origin_url
in
origin_urls
:
print
(
origin_url
)
if
__name__
==
"
__main__
"
:
run
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment