Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ELITERT-1221] Fix crashes with GitHub hosted repos #16

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ Please mark backwards incompatible changes with an exclamation mark at the start

## [Unreleased]

### Fixed
- Dragnet no longer crashes when generating an HTML report for a repository
hosted on Github.

## [5.3.0] - 2024-12-03

### Added
Expand Down
3 changes: 2 additions & 1 deletion lib/dragnet/repository.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

require 'forwardable'
require 'git/url'

require_relative 'base_repository'

Expand Down Expand Up @@ -36,7 +37,7 @@ def head
#
# @return [String] The URI path of the repository
def remote_uri_path
URI.parse(git.remotes.first.url).path
Git::URL.parse(git.remotes.first.url).path
end

# @return [FalseClass] It always returns false
Expand Down
50 changes: 47 additions & 3 deletions spec/dragnet/repository_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,12 @@
describe '#remote_uri_path' do
subject(:method_call) { repository.remote_uri_path }

let(:remote_url) { 'ssh://[email protected]:29418/projects/central/bsw' }

let(:remote) do
instance_double(
Git::Remote,
url: 'ssh://[email protected]:29418/projects/central/bsw'
url: remote_url
)
end

Expand All @@ -109,8 +111,50 @@
method_call
end

it "returns only the path of the remote's URL" do
expect(method_call).to eq('/projects/central/bsw')
context 'when the URL is a standard SSH url' do
it "returns only the path of the remote's URL" do
expect(method_call).to eq('/projects/central/bsw')
end
end

context 'when the URL is a Git URL' do
let(:remote_url) { 'git://[email protected]/esrlabs/dox.git' }

it "returns only the path of the remote's URL" do
expect(method_call).to eq('/esrlabs/dox.git')
end
end

context 'when the URL is a GitHub URL' do
let(:remote_url) { '[email protected]:esrlabs/dox.git' }

it "returns only the path of the remote's URL" do
expect(method_call).to eq('/esrlabs/dox.git')
end
end

context 'when the URL is an HTTPS URL' do
let(:remote_url) { 'https://github.com/esrlabs/dox.git' }

it "returns only the path of the remote's URL" do
expect(method_call).to eq('/esrlabs/dox.git')
end
end

context 'when the URL is a file URL' do
let(:remote_url) { '~/Projects/esrlabs/dox' }

it "returns only the path of the remote's URL" do
expect(method_call).to eq('~/Projects/esrlabs/dox')
end
end

context 'when the URL is a JOSH URL' do
let(:remote_url) { 'https://[email protected]/bsw.git:/libs.git' }

it "returns only the path of the remote's URL" do
expect(method_call).to eq('/bsw.git:/libs.git')
end
end
end

Expand Down
Loading