gitlab_exception_notification 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e50cdaeeea3ed9e989d8d904e3b9b4a1ab7b8a66
|
4
|
+
data.tar.gz: a76c1afbc2e1d32ae9dfe308c0103c39750ec1db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9eaece63cd52733ed35a9693c89b3dbecde2e30deba07d6dc6001c5a850ded29b98787d79b575f943e30edb2e2e297834ff387df6ac4585697562f5669e3ac3c
|
7
|
+
data.tar.gz: 7e4efa688a4450cc7bcbdc59298a17bbd9d978016bd1c0fac143619a9db064d43529df5ddab92e496b1708f12a8dabd7aa6d43a1052390d3a02ed8e6ab0e543c
|
@@ -1,11 +1,10 @@
|
|
1
|
-
|
1
|
+
require "gitlab"
|
2
|
+
require "digest"
|
2
3
|
|
3
|
-
|
4
|
-
require 'digest'
|
4
|
+
module GitlabExceptionNotification
|
5
5
|
|
6
6
|
REJECT_HEADERS = /HTTP_COOKIE|(rack.*)|(action_dispatch.*)/
|
7
|
-
SLINE = "
|
8
|
-
"
|
7
|
+
SLINE = "\n"
|
9
8
|
STAB = SLINE + " "
|
10
9
|
|
11
10
|
PER_PAGE = 40
|
@@ -3,6 +3,7 @@
|
|
3
3
|
module ExceptionNotifier
|
4
4
|
class GitlabNotifier
|
5
5
|
def initialize(options)
|
6
|
+
puts "On init, options => #{options.inspect}"
|
6
7
|
@options = options
|
7
8
|
end
|
8
9
|
|
@@ -17,8 +18,9 @@ module ExceptionNotifier
|
|
17
18
|
end
|
18
19
|
|
19
20
|
def call(exception, options={})
|
21
|
+
puts "On call, exception => #{exception.inspect}, options => #{options.inspect}"
|
20
22
|
env = options[:env] || {}
|
21
23
|
exception_notification(env, exception, @options.merge(options))
|
22
24
|
end
|
23
25
|
end
|
24
|
-
end
|
26
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module GitlabExceptionNotification
|
2
2
|
|
3
3
|
class Issue
|
4
|
-
|
4
|
+
|
5
5
|
def initialize(env, exception, options={})
|
6
6
|
@env = env
|
7
7
|
@exception = exception
|
@@ -10,13 +10,14 @@ module GitlabExceptionNotification
|
|
10
10
|
@request = ActionDispatch::Request.new(env)
|
11
11
|
@data = (env['exception_notifier.exception_data'] || {}).merge(options[:data] || {})
|
12
12
|
@digest = digest
|
13
|
-
@client = Gitlab.client(endpoint:
|
13
|
+
@client = Gitlab.client(endpoint: options[:gitlab_url], private_token: options[:private_token])
|
14
14
|
@project_id = @client.project_search(options[:project_name]).first.id
|
15
15
|
@issues = self.all
|
16
16
|
end
|
17
17
|
|
18
18
|
def create
|
19
|
-
|
19
|
+
puts "create_issue with labels: #{[Rails.env, 'bug'].join(',').inspect}"
|
20
|
+
@client.create_issue(@project_id, title, {description: description, labels: [Rails.env, 'bug'].join(',')})
|
20
21
|
end
|
21
22
|
|
22
23
|
def update(id)
|
@@ -24,7 +25,7 @@ module GitlabExceptionNotification
|
|
24
25
|
last = issue.updated_at.to_date
|
25
26
|
if last < 1.hour.ago
|
26
27
|
begin
|
27
|
-
@client.edit_issue(@project_id, id, {state_event: "reopen"})
|
28
|
+
@client.edit_issue(@project_id, id, {state_event: "reopen", labels: [Rails.env, 'bug'].join(',')})
|
28
29
|
iss = @client.edit_issue(@project_id, id, {title: increment_title(issue)})
|
29
30
|
rescue Exception => e
|
30
31
|
p "An error occured: #{e.inspect}"
|
@@ -41,7 +42,7 @@ module GitlabExceptionNotification
|
|
41
42
|
|
42
43
|
def is_same_exception? issue
|
43
44
|
return false if issue.nil? or issue.description.nil?
|
44
|
-
issue.description.split(SLINE).last.strip == @digest
|
45
|
+
issue.description.split(SLINE).last && issue.description.split(SLINE).last.strip == @digest
|
45
46
|
end
|
46
47
|
|
47
48
|
def exists?
|
@@ -54,10 +55,10 @@ module GitlabExceptionNotification
|
|
54
55
|
|
55
56
|
def all
|
56
57
|
page = 1
|
57
|
-
i = @client.issues(@project_id, per_page: PER_PAGE, page: page, order_by: :updated_at)
|
58
|
+
i = @client.issues(@project_id, per_page: PER_PAGE, page: page, order_by: :updated_at, labels: [Rails.env, 'bug'].join(','))
|
58
59
|
@issues = i
|
59
60
|
while i.count == PER_PAGE
|
60
|
-
i = @client.issues(@project_id, per_page: PER_PAGE, page: page, order_by: :updated_at)
|
61
|
+
i = @client.issues(@project_id, per_page: PER_PAGE, page: page, order_by: :updated_at, labels: [Rails.env, 'bug'].join(','))
|
61
62
|
@issues += i
|
62
63
|
page += 1
|
63
64
|
end
|
@@ -72,8 +73,6 @@ module GitlabExceptionNotification
|
|
72
73
|
# The issue title
|
73
74
|
def title
|
74
75
|
t = []
|
75
|
-
t << "#{@kontroller.controller_name}##{@kontroller.action_name}" if @kontroller
|
76
|
-
t << "(#{@exception.class})"
|
77
76
|
t << (@exception.message.length > 120 ? @exception.message[0..120] + "..." : @exception.message)
|
78
77
|
t.join(' ')
|
79
78
|
end
|
@@ -98,9 +97,12 @@ module GitlabExceptionNotification
|
|
98
97
|
|
99
98
|
# Get the concerned file
|
100
99
|
file = @exception.backtrace.first
|
100
|
+
repo_file = file.gsub(/.*\/#{@options[:project_name]}\/([^:]*):(\d*)(:in.*)/, '\1#L\2')
|
101
|
+
|
102
|
+
d = ["> (#{@exception.class}) #{@exception.message} #{@kontroller ? 'in controller ' + @kontroller.controller_name + '#' + @kontroller.action_name : ''}"]
|
101
103
|
|
102
|
-
d
|
103
|
-
d << "File
|
104
|
+
d << "\n**Full path**: #{file}"
|
105
|
+
d << "\n**File**: [#{repo_file}](#{repo_file})"
|
104
106
|
{
|
105
107
|
'Summary': summary.map { |k, v| "- #{k}: #{v}"}.join(SLINE),
|
106
108
|
'session id': @request.ssl? ? "[FILTERED]" : (@request.session['session_id'] || (@request.env["rack.session.options"] and @request.env["rack.session.options"][:id])).inspect,
|
@@ -109,8 +111,8 @@ module GitlabExceptionNotification
|
|
109
111
|
'request headers': md_hash(@request.headers),
|
110
112
|
'environment': md_hash(@env.reject{|k, v| (REJECT_HEADERS =~ k).nil? })
|
111
113
|
}.reject{|k, v| v.nil? or v.blank?}.each do |k, v|
|
112
|
-
d << "
|
113
|
-
d << "#### #{k.to_s.humanize}
|
114
|
+
d << "\n--------------------------------\n"
|
115
|
+
d << "#### #{k.to_s.humanize}:\n"
|
114
116
|
d << v.to_s
|
115
117
|
end
|
116
118
|
d << @digest
|
@@ -132,11 +134,14 @@ module GitlabExceptionNotification
|
|
132
134
|
def md_hash hash, pre = ""
|
133
135
|
hash.map { |k, v| "#{pre}- **#{k}**: `#{v}`"}.join(SLINE)
|
134
136
|
end
|
135
|
-
|
137
|
+
|
136
138
|
def digest
|
139
|
+
puts "Creating digest with: "
|
140
|
+
puts "- #{@exception.to_s}"
|
141
|
+
puts "- #{@exception.backtrace.first.split(":in").first.to_s}"
|
137
142
|
"EXC" + Digest::SHA256.hexdigest(@exception.to_s + @exception.backtrace.first.split(":in").first.to_s)
|
138
143
|
end
|
139
144
|
|
140
145
|
|
141
146
|
end
|
142
|
-
end
|
147
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitlab_exception_notification
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andre Aubin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -56,20 +56,20 @@ dependencies:
|
|
56
56
|
requirements:
|
57
57
|
- - ">="
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
version: '3.
|
59
|
+
version: '3.7'
|
60
60
|
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: 3.
|
62
|
+
version: 3.7.0
|
63
63
|
type: :runtime
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
67
|
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: '3.
|
69
|
+
version: '3.7'
|
70
70
|
- - ">="
|
71
71
|
- !ruby/object:Gem::Version
|
72
|
-
version: 3.
|
72
|
+
version: 3.7.0
|
73
73
|
description: Automatically create, open and updates Gitlab issues on rails exceptions.
|
74
74
|
email:
|
75
75
|
- andre.aubin@lambdaweb.fr
|
@@ -139,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
139
|
version: '0'
|
140
140
|
requirements: []
|
141
141
|
rubyforge_project:
|
142
|
-
rubygems_version: 2.
|
142
|
+
rubygems_version: 2.5.1
|
143
143
|
signing_key:
|
144
144
|
specification_version: 4
|
145
145
|
summary: A Gitlab plugin for the exception_notification gem.
|