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

Add gitlab? #5

Merged
merged 1 commit into from
Dec 15, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/gitable/uri.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def self.heuristic_parse(uri)
# Addressable::URI.heuristic_parse _does_ return the correct type :)
gitable = super # boo inconsistency

if gitable.github? || gitable.bitbucket?
if gitable.github? || gitable.bitbucket? || gitable.gitlab?
gitable.extname = "git"
end
gitable
Expand All @@ -110,6 +110,13 @@ def github?
!!normalized_host.to_s.match(/\.?github.com$/)
end

# Is this uri a gitlab uri?
#
# @return [Boolean] gitlab.com is the host?
def gitlab?
!!normalized_host.to_s.match(/\.?gitlab.com$/)
end

# Is this uri a bitbucket uri?
#
# @return [Boolean] bitbucket.org is the host?
Expand Down
10 changes: 10 additions & 0 deletions spec/gitable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,7 @@
:authenticated? => true,
:interactive_authenticated? => false,
:github? => true,
:gitlab? => false,
:bitbucket? => false,
:to_web_uri => Addressable::URI.parse("https://github.com/martinemde/gitable"),
})
Expand Down Expand Up @@ -603,6 +604,7 @@
:ssh? => false,
:scp? => false,
:github? => true,
:gitlab? => false,
:bitbucket? => false,
:to_web_uri => Addressable::URI.parse("https://github.com/martinemde/gitable"),
})
Expand Down Expand Up @@ -632,6 +634,7 @@
:ssh? => false,
:scp? => false,
:github? => true,
:gitlab? => false,
:bitbucket? => false,
:authenticated? => true,
:interactive_authenticated? => true,
Expand Down Expand Up @@ -662,6 +665,7 @@
:ssh? => false,
:scp? => false,
:github? => true,
:gitlab? => false,
:bitbucket? => false,
:authenticated? => false,
:interactive_authenticated? => false,
Expand Down Expand Up @@ -695,6 +699,7 @@
:authenticated? => true,
:interactive_authenticated? => false,
:github? => true,
:gitlab? => false,
:bitbucket? => false,
:to_web_uri => Addressable::URI.parse("https://github.com/martinemde/gitable"),
})
Expand Down Expand Up @@ -725,6 +730,7 @@
:authenticated? => true,
:interactive_authenticated? => false,
:github? => false,
:gitlab? => false,
:bitbucket? => true,
:to_web_uri => Addressable::URI.parse("https://bitbucket.org/martinemde/gitable"),
})
Expand Down Expand Up @@ -753,6 +759,7 @@
:ssh? => false,
:scp? => false,
:github? => false,
:gitlab? => false,
:bitbucket? => true,
:to_web_uri => Addressable::URI.parse("https://bitbucket.org/martinemde/gitable"),
})
Expand Down Expand Up @@ -782,6 +789,7 @@
:ssh? => false,
:scp? => false,
:github? => false,
:gitlab? => false,
:bitbucket? => true,
:authenticated? => true,
:interactive_authenticated? => true,
Expand Down Expand Up @@ -812,6 +820,7 @@
:ssh? => false,
:scp? => false,
:github? => false,
:gitlab? => false,
:bitbucket? => true,
:authenticated? => false,
:interactive_authenticated? => false,
Expand Down Expand Up @@ -845,6 +854,7 @@
:authenticated? => true,
:interactive_authenticated? => false,
:github? => false,
:gitlab? => false,
:bitbucket? => true,
:to_web_uri => Addressable::URI.parse("https://bitbucket.org/martinemde/gitable"),
})
Expand Down