Skip to content
Snippets Groups Projects
Commit f96aa492 authored by Thomas Schneider's avatar Thomas Schneider
Browse files

Read settings from config file

parent 3aa4eb4d
No related branches found
No related tags found
No related merge requests found
Pipeline #1647 passed
.rtclientrc .rtclientrc
*.cookie *.cookie
config.yml
# Ignore patterns for Ruby # Ignore patterns for Ruby
*.gem *.gem
......
...@@ -4,8 +4,12 @@ source 'https://rubygems.org' ...@@ -4,8 +4,12 @@ source 'https://rubygems.org'
gem 'rt-client', '~> 1.0' gem 'rt-client', '~> 1.0'
gem 'sinatra', '~> 2.0' gem 'sinatra', '~> 2.0'
gem 'sinatra-contrib', '~> 2.0'
group :development do group :development do
gem 'pry', '~> 0.12.2'
gem 'pry-byebug', '~> 3.7'
gem 'rerun', '~> 0.13.0', require: false gem 'rerun', '~> 0.13.0', require: false
gem 'rubocop', '~> 0.76.0', require: false gem 'rubocop', '~> 0.76.0', require: false
gem 'solargraph'
end end
...@@ -2,9 +2,14 @@ GEM ...@@ -2,9 +2,14 @@ GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
ast (2.4.0) ast (2.4.0)
backport (1.1.2)
backports (3.15.0)
byebug (11.0.1)
coderay (1.1.2)
domain_name (0.5.20190701) domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0) unf (>= 0.0.5, < 1.0.0)
ffi (1.11.2) ffi (1.11.2)
htmlentities (4.3.4)
http-accept (1.7.0) http-accept (1.7.0)
http-cookie (1.0.3) http-cookie (1.0.3)
domain_name (~> 0.5) domain_name (~> 0.5)
...@@ -12,14 +17,25 @@ GEM ...@@ -12,14 +17,25 @@ GEM
listen (3.2.0) listen (3.2.0)
rb-fsevent (~> 0.10, >= 0.10.3) rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10) rb-inotify (~> 0.9, >= 0.9.10)
method_source (0.9.2)
mime-types (3.3) mime-types (3.3)
mime-types-data (~> 3.2015) mime-types-data (~> 3.2015)
mime-types-data (3.2019.1009) mime-types-data (3.2019.1009)
mini_portile2 (2.4.0)
multi_json (1.14.1)
mustermann (1.0.3) mustermann (1.0.3)
netrc (0.11.0) netrc (0.11.0)
nokogiri (1.10.5)
mini_portile2 (~> 2.4.0)
parallel (1.19.0) parallel (1.19.0)
parser (2.6.5.0) parser (2.6.5.0)
ast (~> 2.4.0) ast (~> 2.4.0)
pry (0.12.2)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
pry-byebug (3.7.0)
byebug (~> 11.0)
pry (~> 0.10)
rack (2.0.7) rack (2.0.7)
rack-protection (2.0.7) rack-protection (2.0.7)
rack rack
...@@ -34,6 +50,8 @@ GEM ...@@ -34,6 +50,8 @@ GEM
http-cookie (>= 1.0.2, < 2.0) http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0) mime-types (>= 1.16, < 4.0)
netrc (~> 0.8) netrc (~> 0.8)
reverse_markdown (1.3.0)
nokogiri
rt-client (1.0.2) rt-client (1.0.2)
rest-client (~> 2.0, >= 2.0.0) rest-client (~> 2.0, >= 2.0.0)
rubocop (0.76.0) rubocop (0.76.0)
...@@ -49,20 +67,45 @@ GEM ...@@ -49,20 +67,45 @@ GEM
rack (~> 2.0) rack (~> 2.0)
rack-protection (= 2.0.7) rack-protection (= 2.0.7)
tilt (~> 2.0) tilt (~> 2.0)
sinatra-contrib (2.0.7)
backports (>= 2.8.2)
multi_json
mustermann (~> 1.0)
rack-protection (= 2.0.7)
sinatra (= 2.0.7)
tilt (~> 2.0)
solargraph (0.37.2)
backport (~> 1.1)
bundler (>= 1.17.2)
htmlentities (~> 4.3, >= 4.3.4)
jaro_winkler (~> 1.5)
nokogiri (~> 1.9, >= 1.9.1)
parser (~> 2.3)
reverse_markdown (~> 1.0, >= 1.0.5)
rubocop (~> 0.52)
thor (~> 0.19, >= 0.19.4)
tilt (~> 2.0)
yard (~> 0.9)
thor (0.20.3)
tilt (2.0.10) tilt (2.0.10)
unf (0.1.4) unf (0.1.4)
unf_ext unf_ext
unf_ext (0.0.7.6) unf_ext (0.0.7.6)
unicode-display_width (1.6.0) unicode-display_width (1.6.0)
yard (0.9.20)
PLATFORMS PLATFORMS
ruby ruby
DEPENDENCIES DEPENDENCIES
pry (~> 0.12.2)
pry-byebug (~> 3.7)
rerun (~> 0.13.0) rerun (~> 0.13.0)
rt-client (~> 1.0) rt-client (~> 1.0)
rubocop (~> 0.76.0) rubocop (~> 0.76.0)
sinatra (~> 2.0) sinatra (~> 2.0)
sinatra-contrib (~> 2.0)
solargraph
BUNDLED WITH BUNDLED WITH
2.0.2 2.0.2
---
issue_tag: RT
rt:
server: https://rt.example.org/
user: gl-bridge
pass: hunter2
cookies: /srv/www/gl-rt-bridge
...@@ -4,10 +4,16 @@ ...@@ -4,10 +4,16 @@
require 'rt_client' require 'rt_client'
require 'set' require 'set'
require 'sinatra' require 'sinatra'
require 'sinatra/config_file'
ISSUE_TAG = 'FSMPI' config_file 'config.yml'
rt = RT_Client.new rx = /#{settings.issue_tag}[ -]?#(\d+)/
rt = RT_Client.new(server: settings.rt[:server],
user: settings.rt[:user],
pass: settings.rt[:pass],
cookies: settings.rt[:cookies])
post '/' do # rubocop:disable Metrics/BlockLength post '/' do # rubocop:disable Metrics/BlockLength
gitlab_event = request.env['HTTP_X_GITLAB_EVENT'] gitlab_event = request.env['HTTP_X_GITLAB_EVENT']
...@@ -18,7 +24,7 @@ post '/' do # rubocop:disable Metrics/BlockLength ...@@ -18,7 +24,7 @@ post '/' do # rubocop:disable Metrics/BlockLength
# results is a Hash mapping an issue to a set of commits referring to it # results is a Hash mapping an issue to a set of commits referring to it
results = {} results = {}
d[:commits].each do |c| d[:commits].each do |c|
issues = c[:message].scan(/#{ISSUE_TAG}[ -]?#(\d+)/) issues = c[:message].scan rx
# String#scan always returns a list of lists when using capture groups, # String#scan always returns a list of lists when using capture groups,
# even if it's only one # even if it's only one
issues.each do |i, _| issues.each do |i, _|
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment