Skip to content

Commit

Permalink
fix: slug_regex when url has different host
Browse files Browse the repository at this point in the history
  • Loading branch information
ArmandoAssuncao committed Mar 11, 2022
1 parent a84f946 commit fae60ca
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/pronto/gitlab.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,10 @@ def env_pull_id
def slug_regex(url)
if url =~ %r{^ssh:\/\/}
%r{.*#{host}(:[0-9]+)?(:|\/)(?<slug>.*).git}
else
elsif url =~ %r{#{host}}
%r{.*#{host}(:|\/)(?<slug>.*).git}
else
%r{\/\/.*?(\/)(?<slug>.*).git}
end
end

Expand Down
20 changes: 20 additions & 0 deletions spec/pronto/gitlab_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fae60ca

Please sign in to comment.