2018-07-25 08:22:53 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-06-25 16:06:10 -04:00
|
|
|
module BitbucketServer
|
|
|
|
module Representation
|
|
|
|
class Repo < Representation::Base
|
2018-07-26 18:45:38 -04:00
|
|
|
def project_key
|
|
|
|
raw.dig('project', 'key')
|
|
|
|
end
|
|
|
|
|
2018-07-05 17:09:01 -04:00
|
|
|
def project_name
|
|
|
|
raw.dig('project', 'name')
|
|
|
|
end
|
|
|
|
|
2018-06-25 16:06:10 -04:00
|
|
|
def slug
|
|
|
|
raw['slug']
|
|
|
|
end
|
|
|
|
|
2018-07-01 08:55:23 -04:00
|
|
|
def browse_url
|
2019-05-20 10:11:44 -04:00
|
|
|
# The JSON response contains an array of 1 element. Not sure if there
|
2018-07-26 00:45:13 -04:00
|
|
|
# are cases where multiple links would be provided.
|
2018-07-12 18:26:37 -04:00
|
|
|
raw.dig('links', 'self').first.fetch('href')
|
2018-07-01 08:55:23 -04:00
|
|
|
end
|
|
|
|
|
2018-06-26 01:40:11 -04:00
|
|
|
def clone_url
|
|
|
|
raw['links']['clone'].find { |link| link['name'].starts_with?('http') }.fetch('href')
|
2018-06-25 16:06:10 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def description
|
2022-01-24 13:14:42 -05:00
|
|
|
raw['description']
|
2018-06-25 16:06:10 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def full_name
|
2018-07-21 00:46:01 -04:00
|
|
|
"#{project_name}/#{name}"
|
2018-06-25 16:06:10 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def issues_enabled?
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def name
|
|
|
|
raw['name']
|
|
|
|
end
|
|
|
|
|
|
|
|
def valid?
|
|
|
|
raw['scmId'] == 'git'
|
|
|
|
end
|
|
|
|
|
|
|
|
def visibility_level
|
|
|
|
if project['public']
|
|
|
|
Gitlab::VisibilityLevel::PUBLIC
|
|
|
|
else
|
|
|
|
Gitlab::VisibilityLevel::PRIVATE
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def project
|
|
|
|
raw['project']
|
|
|
|
end
|
|
|
|
|
|
|
|
def to_s
|
|
|
|
full_name
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|