From 9143cfe6d2690302db7398c9c482894cbd924d87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armando=20Assun=C3=A7=C3=A3o?= Date: Tue, 5 Apr 2022 05:15:19 -0300 Subject: [PATCH] fix Gitlab#slug_regex when URL has different host --- lib/pronto/gitlab.rb | 4 +++- spec/pronto/gitlab_spec.rb | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/lib/pronto/gitlab.rb b/lib/pronto/gitlab.rb index 3dd658b8..3734d34b 100644 --- a/lib/pronto/gitlab.rb +++ b/lib/pronto/gitlab.rb @@ -87,8 +87,10 @@ def env_pull_id def slug_regex(url) if url =~ %r{^ssh:\/\/} %r{.*#{host}(:[0-9]+)?(:|\/)(?.*).git} - else + elsif url =~ /#{host}/ %r{.*#{host}(:|\/)(?.*).git} + else + %r{\/\/.*?(\/)(?.*).git} end end diff --git a/spec/pronto/gitlab_spec.rb b/spec/pronto/gitlab_spec.rb index 092eec6c..ce6fa2b8 100644 --- a/spec/pronto/gitlab_spec.rb +++ b/spec/pronto/gitlab_spec.rb @@ -29,6 +29,26 @@ module Pronto subject.should eql('prontolabs/pronto') end end + + context 'http remote url' do + let(:repo) do + double(remote_urls: ['https://gitlab.example.com/prontolabs/pronto.git']) + end + + it 'returns correct slug' do + subject.should eql('prontolabs/pronto') + end + end + + context 'http remote url with different host' do + let(:repo) do + double(remote_urls: ['https://gitlab.example.net/prontolabs/pronto.git']) + end + + it 'returns correct slug' do + subject.should eql('prontolabs/pronto') + end + end end describe '#commit_comments' do