Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
524eb1aa
Commit
524eb1aa
authored
Mar 03, 2020
by
syasonik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Accept issues created via global integration
parent
e0d5a134
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
2 deletions
+49
-2
changelogs/unreleased/sy-global-integration.yml
changelogs/unreleased/sy-global-integration.yml
+5
-0
lib/sentry/client/issue.rb
lib/sentry/client/issue.rb
+16
-2
spec/lib/sentry/client/issue_spec.rb
spec/lib/sentry/client/issue_spec.rb
+28
-0
No files found.
changelogs/unreleased/sy-global-integration.yml
0 → 100644
View file @
524eb1aa
---
title
:
Display GitLab issues created via Sentry global integration
merge_request
:
26418
author
:
type
:
fixed
lib/sentry/client/issue.rb
View file @
524eb1aa
...
@@ -75,7 +75,21 @@ module Sentry
...
@@ -75,7 +75,21 @@ module Sentry
http_get
(
api_urls
.
issue_url
(
issue_id
))[
:body
]
http_get
(
api_urls
.
issue_url
(
issue_id
))[
:body
]
end
end
def
parse_gitlab_issue
(
plugin_issues
)
def
parse_gitlab_issue
(
issue
)
parse_issue_annotations
(
issue
)
||
parse_plugin_issue
(
issue
)
end
def
parse_issue_annotations
(
issue
)
issue
.
fetch
(
'annotations'
,
[])
.
reject
(
&
:blank?
)
.
map
{
|
annotation
|
Nokogiri
.
make
(
annotation
)
}
.
find
{
|
html
|
html
[
'href'
]
&
.
starts_with?
(
Gitlab
.
config
.
gitlab
.
url
)
}
.
try
(
:[]
,
'href'
)
end
def
parse_plugin_issue
(
issue
)
plugin_issues
=
issue
.
fetch
(
'pluginIssues'
,
nil
)
return
unless
plugin_issues
return
unless
plugin_issues
gitlab_plugin
=
plugin_issues
.
detect
{
|
item
|
item
[
'id'
]
==
'gitlab'
}
gitlab_plugin
=
plugin_issues
.
detect
{
|
item
|
item
[
'id'
]
==
'gitlab'
}
...
@@ -145,7 +159,7 @@ module Sentry
...
@@ -145,7 +159,7 @@ module Sentry
short_id:
issue
.
fetch
(
'shortId'
,
nil
),
short_id:
issue
.
fetch
(
'shortId'
,
nil
),
status:
issue
.
fetch
(
'status'
,
nil
),
status:
issue
.
fetch
(
'status'
,
nil
),
frequency:
issue
.
dig
(
'stats'
,
'24h'
),
frequency:
issue
.
dig
(
'stats'
,
'24h'
),
gitlab_issue:
parse_gitlab_issue
(
issue
.
fetch
(
'pluginIssues'
,
nil
)
),
gitlab_issue:
parse_gitlab_issue
(
issue
),
project_id:
issue
.
dig
(
'project'
,
'id'
),
project_id:
issue
.
dig
(
'project'
,
'id'
),
project_name:
issue
.
dig
(
'project'
,
'name'
),
project_name:
issue
.
dig
(
'project'
,
'name'
),
project_slug:
issue
.
dig
(
'project'
,
'slug'
),
project_slug:
issue
.
dig
(
'project'
,
'slug'
),
...
...
spec/lib/sentry/client/issue_spec.rb
View file @
524eb1aa
...
@@ -254,6 +254,34 @@ describe Sentry::Client::Issue do
...
@@ -254,6 +254,34 @@ describe Sentry::Client::Issue do
expect
(
subject
.
gitlab_issue
).
to
eq
(
'https://gitlab.com/gitlab-org/gitlab/issues/1'
)
expect
(
subject
.
gitlab_issue
).
to
eq
(
'https://gitlab.com/gitlab-org/gitlab/issues/1'
)
end
end
context
'when issue annotations exist'
do
before
do
issue_sample_response
[
'annotations'
]
=
[
nil
,
''
,
"<a href=
\"
http://github.com/issues/6
\"
>github-issue-6</a>"
,
"<div>annotation</a>"
,
"<a href=
\"
http://localhost/gitlab-org/gitlab/issues/2
\"
>gitlab-org/gitlab#2</a>"
]
stub_sentry_request
(
sentry_request_url
,
body:
issue_sample_response
)
end
it
'has a correct GitLab issue url'
do
expect
(
subject
.
gitlab_issue
).
to
eq
(
'http://localhost/gitlab-org/gitlab/issues/2'
)
end
end
context
'when no GitLab issue is linked'
do
before
do
issue_sample_response
[
'pluginIssues'
]
=
[]
stub_sentry_request
(
sentry_request_url
,
body:
issue_sample_response
)
end
it
'does not find a GitLab issue'
do
expect
(
subject
.
gitlab_issue
).
to
be_nil
end
end
it
'has the correct tags'
do
it
'has the correct tags'
do
expect
(
subject
.
tags
).
to
eq
({
level:
issue_sample_response
[
'level'
],
logger:
issue_sample_response
[
'logger'
]
})
expect
(
subject
.
tags
).
to
eq
({
level:
issue_sample_response
[
'level'
],
logger:
issue_sample_response
[
'logger'
]
})
end
end
...
...
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