Commit f96aa492 authored by Thomas Schneider's avatar Thomas Schneider
Browse files

Read settings from config file

parent 3aa4eb4d
Pipeline #1647 passed with stage
in 3 minutes and 25 seconds
.rtclientrc
*.cookie
config.yml
# Ignore patterns for Ruby
*.gem
......
......@@ -4,8 +4,12 @@ source 'https://rubygems.org'
gem 'rt-client', '~> 1.0'
gem 'sinatra', '~> 2.0'
gem 'sinatra-contrib', '~> 2.0'
group :development do
gem 'pry', '~> 0.12.2'
gem 'pry-byebug', '~> 3.7'
gem 'rerun', '~> 0.13.0', require: false
gem 'rubocop', '~> 0.76.0', require: false
gem 'solargraph'
end
......@@ -2,9 +2,14 @@ GEM
remote: https://rubygems.org/
specs:
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)
unf (>= 0.0.5, < 1.0.0)
ffi (1.11.2)
htmlentities (4.3.4)
http-accept (1.7.0)
http-cookie (1.0.3)
domain_name (~> 0.5)
......@@ -12,14 +17,25 @@ GEM
listen (3.2.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
method_source (0.9.2)
mime-types (3.3)
mime-types-data (~> 3.2015)
mime-types-data (3.2019.1009)
mini_portile2 (2.4.0)
multi_json (1.14.1)
mustermann (1.0.3)
netrc (0.11.0)
nokogiri (1.10.5)
mini_portile2 (~> 2.4.0)
parallel (1.19.0)
parser (2.6.5.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-protection (2.0.7)
rack
......@@ -34,6 +50,8 @@ GEM
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
reverse_markdown (1.3.0)
nokogiri
rt-client (1.0.2)
rest-client (~> 2.0, >= 2.0.0)
rubocop (0.76.0)
......@@ -49,20 +67,45 @@ GEM
rack (~> 2.0)
rack-protection (= 2.0.7)
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)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.6)
unicode-display_width (1.6.0)
yard (0.9.20)
PLATFORMS
ruby
DEPENDENCIES
pry (~> 0.12.2)
pry-byebug (~> 3.7)
rerun (~> 0.13.0)
rt-client (~> 1.0)
rubocop (~> 0.76.0)
sinatra (~> 2.0)
sinatra-contrib (~> 2.0)
solargraph
BUNDLED WITH
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 @@
require 'rt_client'
require 'set'
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
gitlab_event = request.env['HTTP_X_GITLAB_EVENT']
......@@ -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 = {}
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,
# even if it's only one
issues.each do |i, _|
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment