debian-mirror-gitlab/lib/api/version.rb

31 lines
702 B
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
2016-11-03 12:29:30 +05:30
module API
class Version < Grape::API
2019-05-18 00:54:41 +05:30
helpers ::API::Helpers::GraphqlHelpers
2016-11-03 12:29:30 +05:30
before { authenticate! }
2019-05-18 00:54:41 +05:30
METADATA_QUERY = <<~EOF
{
metadata {
version
revision
}
}
EOF
2016-11-03 12:29:30 +05:30
desc 'Get the version information of the GitLab instance.' do
detail 'This feature was introduced in GitLab 8.13.'
end
get '/version' do
2019-05-18 00:54:41 +05:30
conditionally_graphql!(
query: METADATA_QUERY,
context: { current_user: current_user },
transform: ->(result) { result.dig('data', 'metadata') },
fallback: -> { { version: Gitlab::VERSION, revision: Gitlab.revision } }
)
2016-11-03 12:29:30 +05:30
end
end
end