From d7cbfe808ac713038c25a1b9b514178fcd72e415 Mon Sep 17 00:00:00 2001 From: ArmandoAssuncao Date: Thu, 10 Mar 2022 20:54:03 -0300 Subject: [PATCH] fix: 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