summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-03 18:08:16 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-03 18:08:16 +0000
commite9c2bf267862e22c0770cc7b3a1ed97a8b87a7fd (patch)
tree7b778e44f210132af1233ceb8801b388ac3519f5 /lib
parent946771d0b016ae92b15a60bc3290a33b94191ffe (diff)
downloadgitlab-ce-e9c2bf267862e22c0770cc7b3a1ed97a8b87a7fd.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r--lib/api/entities/commit.rb4
-rw-r--r--lib/api/helpers/groups_helpers.rb2
-rw-r--r--lib/api/project_snippets.rb5
-rw-r--r--lib/api/remote_mirrors.rb20
-rw-r--r--lib/gitlab/url_builder.rb5
5 files changed, 34 insertions, 2 deletions
diff --git a/lib/api/entities/commit.rb b/lib/api/entities/commit.rb
index 7ce97c2c3d8..3eaf896f1ac 100644
--- a/lib/api/entities/commit.rb
+++ b/lib/api/entities/commit.rb
@@ -9,6 +9,10 @@ module API
expose :safe_message, as: :message
expose :author_name, :author_email, :authored_date
expose :committer_name, :committer_email, :committed_date
+
+ expose :web_url do |commit, _options|
+ Gitlab::UrlBuilder.build(commit)
+ end
end
end
end
diff --git a/lib/api/helpers/groups_helpers.rb b/lib/api/helpers/groups_helpers.rb
index 25701ff683d..f3dfc093926 100644
--- a/lib/api/helpers/groups_helpers.rb
+++ b/lib/api/helpers/groups_helpers.rb
@@ -11,6 +11,8 @@ module API
optional :visibility, type: String,
values: Gitlab::VisibilityLevel.string_values,
desc: 'The visibility of the group'
+ # TODO: remove rubocop disable - https://gitlab.com/gitlab-org/gitlab/issues/14960
+ optional :avatar, type: File, desc: 'Avatar image for the group' # rubocop:disable Scalability/FileUploads
optional :share_with_group_lock, type: Boolean, desc: 'Prevent sharing a project with another group within this group'
optional :require_two_factor_authentication, type: Boolean, desc: 'Require all users in this group to setup Two-factor authentication'
optional :two_factor_grace_period, type: Integer, desc: 'Time before Two-factor authentication is enforced'
diff --git a/lib/api/project_snippets.rb b/lib/api/project_snippets.rb
index 3040c3c27c6..e8234a9285c 100644
--- a/lib/api/project_snippets.rb
+++ b/lib/api/project_snippets.rb
@@ -5,12 +5,17 @@ module API
include PaginationParams
before { authenticate! }
+ before { check_snippets_enabled }
params do
requires :id, type: String, desc: 'The ID of a project'
end
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
helpers do
+ def check_snippets_enabled
+ forbidden! unless user_project.feature_available?(:snippets, current_user)
+ end
+
def handle_project_member_errors(errors)
if errors[:project_access].any?
error!(errors[:project_access], 422)
diff --git a/lib/api/remote_mirrors.rb b/lib/api/remote_mirrors.rb
index 95313966133..bdaec67108d 100644
--- a/lib/api/remote_mirrors.rb
+++ b/lib/api/remote_mirrors.rb
@@ -26,6 +26,26 @@ module API
with: Entities::RemoteMirror
end
+ desc 'Create remote mirror for a project' do
+ success Entities::RemoteMirror
+ end
+ params do
+ requires :url, type: String, desc: 'The URL for a remote mirror'
+ optional :enabled, type: Boolean, desc: 'Determines if the mirror is enabled'
+ optional :only_protected_branches, type: Boolean, desc: 'Determines if only protected branches are mirrored'
+ end
+ post ':id/remote_mirrors' do
+ create_params = declared_params(include_missing: false)
+
+ new_mirror = user_project.remote_mirrors.create(create_params)
+
+ if new_mirror.persisted?
+ present new_mirror, with: Entities::RemoteMirror
+ else
+ render_validation_error!(new_mirror)
+ end
+ end
+
desc 'Update the attributes of a single remote mirror' do
success Entities::RemoteMirror
end
diff --git a/lib/gitlab/url_builder.rb b/lib/gitlab/url_builder.rb
index 4bedf7a301e..cc53e3b7577 100644
--- a/lib/gitlab/url_builder.rb
+++ b/lib/gitlab/url_builder.rb
@@ -13,7 +13,8 @@ module Gitlab
end
def url
- case object
+ # Objects are sometimes wrapped in a BatchLoader instance
+ case object.itself
when Commit
commit_url
when Issue
@@ -33,7 +34,7 @@ module Gitlab
when User
user_url(object)
else
- raise NotImplementedError.new("No URL builder defined for #{object.class}")
+ raise NotImplementedError.new("No URL builder defined for #{object.inspect}")
end
end