Skip to content

Commit

Permalink
FIXUP
Browse files Browse the repository at this point in the history
  • Loading branch information
neomilium committed Apr 21, 2021
1 parent 7e0a87f commit 020c608
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/modulesync/git_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ class Error < StandardError; end

# Namespace for Git service classes (ie. GitHub, GitLab)
module GitService
class MissingCredentialsError < Error; end
class MissingCredentialsError < Error; end

def self.instantiate(type:, options:)
def self.instantiate(type:, options:)
options ||= {}
case type
when :github
Expand Down Expand Up @@ -47,7 +47,7 @@ def self.type_for(sourcecode:)

if ENV['GITLAB_TOKEN'].nil? && ENV['GITHUB_TOKEN'].nil?
raise ModuleSync::Error, <<~MESSAGE
Unable to guess Git service type with none GITLAB_TOKEN or GITHUB_TOKEN sets.
Unable to guess Git service type without GITLAB_TOKEN or GITHUB_TOKEN sets.
MESSAGE
end

Expand Down Expand Up @@ -90,7 +90,7 @@ def self.endpoint_for(sourcecode:, type:)
def self.guess_endpoint_from(remote:, type:)
pattern = /^git@(.*):(.*)(\.git)*$/
return nil unless remote.match?(pattern)

endpoint = remote.sub(pattern, 'https://\1')
endpoint += '/api/v4' if type == :gitlab
endpoint
Expand All @@ -100,7 +100,8 @@ def self.guess_endpoint_from(remote:, type:)
# 2. environment variable depending on type
# 3. fails
def self.token_for(sourcecode:, type:)
return sourcecode.options[type][:token] unless sourcecode.options.dig(type, :token).nil?
token = sourcecode.options.dig(type, :token)
return token unless token.nil?

token = case type
when :github
Expand Down

0 comments on commit 020c608

Please sign in to comment.