Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
6c0ae72c
Commit
6c0ae72c
authored
Nov 03, 2014
by
Marin Jankovski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add project git hooks api.
parent
e180e6d5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
82 additions
and
0 deletions
+82
-0
lib/api/api.rb
lib/api/api.rb
+1
-0
lib/api/entities.rb
lib/api/entities.rb
+5
-0
lib/api/project_git_hooks.rb
lib/api/project_git_hooks.rb
+76
-0
No files found.
lib/api/api.rb
View file @
6c0ae72c
...
...
@@ -41,6 +41,7 @@ module API
mount
ProjectMembers
mount
DeployKeys
mount
ProjectHooks
mount
ProjectGitHooks
mount
Ldap
mount
Services
mount
Files
...
...
lib/api/entities.rb
View file @
6c0ae72c
...
...
@@ -34,6 +34,11 @@ module API
expose
:issues_events
,
:merge_requests_events
,
:tag_push_events
end
class
ProjectGitHook
<
Grape
::
Entity
expose
:id
,
:project_id
,
:created_at
expose
:commit_message_regex
,
:deny_delete_tag
end
class
ForkedFromProject
<
Grape
::
Entity
expose
:id
expose
:name
,
:name_with_namespace
...
...
lib/api/project_git_hooks.rb
0 → 100644
View file @
6c0ae72c
module
API
# Projects git hook API
class
ProjectGitHooks
<
Grape
::
API
before
{
authenticate!
}
before
{
authorize_admin_project
}
resource
:projects
do
# Get project git hook
#
# Parameters:
# id (required) - The ID of a project
# Example Request:
# GET /projects/:id/git_hook
get
":id/git_hook"
do
@git_hooks
=
user_project
.
git_hook
present
@git_hooks
,
with:
Entities
::
ProjectGitHook
end
# Add git hook to project
#
# Parameters:
# id (required) - The ID of a project
# Example Request:
# POST /projects/:id/git_hook
post
":id/git_hook"
do
attrs
=
attributes_for_keys
[
:commit_message_regex
,
:deny_delete_tag
]
if
user_project
.
git_hook
error!
(
"Project git hook exists"
,
422
)
else
@git_hook
=
user_project
.
create_git_hook
(
attrs
)
present
@git_hook
,
with:
Entities
::
ProjectGitHook
end
end
# Update an existing project git hook
#
# Parameters:
# id (required) - The ID of a project
# Example Request:
# PUT /projects/:id/git_hook
put
":id/git_hook"
do
@git_hook
=
user_project
.
git_hook
attrs
=
attributes_for_keys
[
:commit_message_regex
,
:deny_delete_tag
]
if
@git_hook
.
update_attributes
attrs
present
@git_hook
,
with:
Entities
::
ProjectGitHook
else
not_found!
end
end
# Deletes project git hook. This is an idempotent function.
#
# Parameters:
# id (required) - The ID of a project
# Example Request:
# DELETE /projects/:id/git_hook
delete
":id/git_hook"
do
@git_hook
=
user_project
.
git_hook
if
@git_hook
@git_hook
.
destroy
else
not_found!
end
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment