Commit 2ac67b2e authored by Robert Schilling's avatar Robert Schilling

Remove ProjectGitHook API

parent 2b34fba1
---
title: 'API: Remove the ProjectGitHook API'
merge_request: 1301
author: Robert Schilling
......@@ -40,4 +40,5 @@ changes are in V4:
- POST/PUT/DELETE `:id/repository/files`
- Renamed `branch_name` to `branch` on DELETE `id/repository/branches/:branch` response [!8936](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/8936)
- Remove `public` param from create and edit actions of projects [!8736](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/8736)
- Remove the ProjectGitHook API. Use the ProjectPushRule API instead [!1301](https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/1301)
- Notes do not return deprecated field `upvote` and `downvote` [!9384](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/9384)
......@@ -16,6 +16,7 @@ module API
mount ::API::V3::MergeRequestDiffs
mount ::API::V3::MergeRequests
mount ::API::V3::Notes
mount ::API::V3::ProjectGitHook
mount ::API::V3::ProjectHooks
mount ::API::V3::Projects
mount ::API::V3::ProjectSnippets
......@@ -90,7 +91,6 @@ module API
mount ::API::Notes
mount ::API::NotificationSettings
mount ::API::Pipelines
mount ::API::ProjectGitHook # TODO: Should be removed after 8.11 is released
mount ::API::ProjectHooks
mount ::API::ProjectPushRule
mount ::API::Projects
......
# TODO: These end-points are deprecated and replaced with push_rules
# and should be removed after GitLab 9.0 is released
module API
# Projects push rule API
class ProjectGitHook < Grape::API
before { authenticate! }
before { authorize_admin_project }
DEPRECATION_MESSAGE = 'This endpoint is deprecated, replaced with push_rules, and will be removed in GitLab 9.0.'.freeze
params do
requires :id, type: String, desc: 'The ID of a project'
end
resource :projects do
helpers do
params :push_rule_params do
optional :commit_message_regex, type: String, desc: 'The commit message regex'
optional :deny_delete_tag, type: Boolean, desc: 'Deny deleting a tag'
at_least_one_of :commit_message_regex, :deny_delete_tag
end
end
desc 'Get project push rule' do
success Entities::ProjectPushRule
detail DEPRECATION_MESSAGE
end
get ":id/git_hook" do
push_rule = user_project.push_rule
present push_rule, with: Entities::ProjectPushRule
end
desc 'Add a push rule to a project' do
success Entities::ProjectPushRule
detail DEPRECATION_MESSAGE
end
params do
use :push_rule_params
end
post ":id/git_hook" do
if user_project.push_rule
error!("Project push rule exists", 422)
else
push_rule = user_project.create_push_rule(declared_params)
present push_rule, with: Entities::ProjectPushRule
end
end
desc 'Update an existing project push rule' do
success Entities::ProjectPushRule
detail DEPRECATION_MESSAGE
end
params do
use :push_rule_params
end
put ":id/git_hook" do
push_rule = user_project.push_rule
not_found!('Push Rule') unless push_rule
if push_rule.update_attributes(declared_params(include_missing: false))
present push_rule, with: Entities::ProjectPushRule
else
render_validation_error!(push_rule)
end
end
desc 'Deletes project push rule' do
detail DEPRECATION_MESSAGE
end
delete ":id/git_hook" do
push_rule = user_project.push_rule
not_found!('Push Rule') unless push_rule
push_rule.destroy
end
end
end
end
module API
module V3
class ProjectGitHook < Grape::API
before { authenticate! }
before { authorize_admin_project }
DEPRECATION_MESSAGE = 'This endpoint is deprecated, replaced with push_rules, and will be removed in GitLab 9.0.'.freeze
params do
requires :id, type: String, desc: 'The ID of a project'
end
resource :projects do
helpers do
params :push_rule_params do
optional :commit_message_regex, type: String, desc: 'The commit message regex'
optional :deny_delete_tag, type: Boolean, desc: 'Deny deleting a tag'
at_least_one_of :commit_message_regex, :deny_delete_tag
end
end
desc 'Get project push rule' do
success ::API::Entities::ProjectPushRule
detail DEPRECATION_MESSAGE
end
get ":id/git_hook" do
push_rule = user_project.push_rule
present push_rule, with: ::API::Entities::ProjectPushRule
end
desc 'Add a push rule to a project' do
success ::API::Entities::ProjectPushRule
detail DEPRECATION_MESSAGE
end
params do
use :push_rule_params
end
post ":id/git_hook" do
if user_project.push_rule
error!("Project push rule exists", 422)
else
push_rule = user_project.create_push_rule(declared_params)
present push_rule, with: ::API::Entities::ProjectPushRule
end
end
desc 'Update an existing project push rule' do
success ::API::Entities::ProjectPushRule
detail DEPRECATION_MESSAGE
end
params do
use :push_rule_params
end
put ":id/git_hook" do
push_rule = user_project.push_rule
not_found!('Push Rule') unless push_rule
if push_rule.update_attributes(declared_params(include_missing: false))
present push_rule, with: ::API::Entities::ProjectPushRule
else
render_validation_error!(push_rule)
end
end
desc 'Deletes project push rule' do
detail DEPRECATION_MESSAGE
end
delete ":id/git_hook" do
push_rule = user_project.push_rule
not_found!('Push Rule') unless push_rule
push_rule.destroy
end
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment