Skip to content

Commit

Permalink
Merge pull request #87 from modosc/fix-slug-parsing
Browse files Browse the repository at this point in the history
handle github remote urls without .git suffix
  • Loading branch information
mmozuras committed Sep 20, 2015
2 parents 27b2de2 + ce35e6b commit c635341
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/pronto/github.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def create_pull_comment(comment)
def slug
@slug ||= begin
@repo.remote_urls.map do |url|
match = /.*github.com(:|\/)(?<slug>.*).git/.match(url)
match = /.*github.com(:|\/)(?<slug>.*?)(?:\.git)?\z/.match(url)
match[:slug] if match
end.compact.first
end
Expand Down
17 changes: 17 additions & 0 deletions spec/pronto/github_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,23 @@ module Pronto
let(:sha) { '61e4bef' }
let(:comment) { double(body: 'note', path: 'path', line: 1, position: 1) }

describe '#slug' do
let(:repo) { double(remote_urls: ['git@github.com:mmozuras/pronto']) }
subject { github.commit_comments(sha) }

context 'git remote without .git suffix' do
specify do
Octokit::Client.any_instance
.should_receive(:commit_comments)
.with('mmozuras/pronto', sha)
.once
.and_return([comment])

subject
end
end
end

describe '#commit_comments' do
subject { github.commit_comments(sha) }

Expand Down

0 comments on commit c635341

Please # to comment.