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