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
0
Merge Requests
0
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
Kazuhiko Shiozaki
gitlab-ce
Commits
ae18ba16
Commit
ae18ba16
authored
Nov 24, 2015
by
Valery Sizov
Committed by
Valery Sizov
Nov 30, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fire update hook from GitLab
parent
a8e05cec
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
3 deletions
+25
-3
CHANGELOG
CHANGELOG
+1
-0
app/models/repository.rb
app/models/repository.rb
+7
-3
lib/gitlab/git/hook.rb
lib/gitlab/git/hook.rb
+17
-0
No files found.
CHANGELOG
View file @
ae18ba16
...
@@ -7,6 +7,7 @@ v 8.3.0 (unreleased)
...
@@ -7,6 +7,7 @@ v 8.3.0 (unreleased)
- Fix 500 error when update group member permission
- Fix 500 error when update group member permission
- Fix: Raw private snippets access workflow
- Fix: Raw private snippets access workflow
- Trim leading and trailing whitespace of milestone and issueable titles (Jose Corcuera)
- Trim leading and trailing whitespace of milestone and issueable titles (Jose Corcuera)
- Fire update hook from GitLab
v 8.2.1
v 8.2.1
- Forcefully update builds that didn't want to update with state machine
- Forcefully update builds that didn't want to update with state machine
...
...
app/models/repository.rb
View file @
ae18ba16
...
@@ -571,9 +571,13 @@ class Repository
...
@@ -571,9 +571,13 @@ class Repository
# Run GitLab pre-receive hook
# Run GitLab pre-receive hook
pre_receive_hook
=
Gitlab
::
Git
::
Hook
.
new
(
'pre-receive'
,
path_to_repo
)
pre_receive_hook
=
Gitlab
::
Git
::
Hook
.
new
(
'pre-receive'
,
path_to_repo
)
status
=
pre_receive_hook
.
trigger
(
gl_id
,
oldrev
,
newrev
,
ref
)
pre_receive_hook_
status
=
pre_receive_hook
.
trigger
(
gl_id
,
oldrev
,
newrev
,
ref
)
if
status
# Run GitLab update hook
update_hook
=
Gitlab
::
Git
::
Hook
.
new
(
'update'
,
path_to_repo
)
update_hook_status
=
update_hook
.
trigger
(
gl_id
,
oldrev
,
newrev
,
ref
)
if
pre_receive_hook_status
&&
update_hook_status
if
was_empty
if
was_empty
# Create branch
# Create branch
rugged
.
references
.
create
(
ref
,
newrev
)
rugged
.
references
.
create
(
ref
,
newrev
)
...
@@ -596,7 +600,7 @@ class Repository
...
@@ -596,7 +600,7 @@ class Repository
# Remove tmp ref and return error to user
# Remove tmp ref and return error to user
rugged
.
references
.
delete
(
tmp_ref
)
rugged
.
references
.
delete
(
tmp_ref
)
raise
PreReceiveError
.
new
(
'Commit was rejected by
pre-receive
hook'
)
raise
PreReceiveError
.
new
(
'Commit was rejected by
git
hook'
)
end
end
end
end
...
...
lib/gitlab/git/hook.rb
View file @
ae18ba16
...
@@ -16,6 +16,17 @@ module Gitlab
...
@@ -16,6 +16,17 @@ module Gitlab
def
trigger
(
gl_id
,
oldrev
,
newrev
,
ref
)
def
trigger
(
gl_id
,
oldrev
,
newrev
,
ref
)
return
true
unless
exists?
return
true
unless
exists?
case
name
when
"pre-receive"
,
"post-receive"
call_receive_hook
(
gl_id
,
oldrev
,
newrev
,
ref
)
when
"update"
call_update_hook
(
gl_id
,
oldrev
,
newrev
,
ref
)
end
end
private
def
call_receive_hook
(
gl_id
,
oldrev
,
newrev
,
ref
)
changes
=
[
oldrev
,
newrev
,
ref
].
join
(
" "
)
changes
=
[
oldrev
,
newrev
,
ref
].
join
(
" "
)
# function will return true if succesful
# function will return true if succesful
...
@@ -54,6 +65,12 @@ module Gitlab
...
@@ -54,6 +65,12 @@ module Gitlab
exit_status
exit_status
end
end
def
call_update_hook
(
gl_id
,
oldrev
,
newrev
,
ref
)
Dir
.
chdir
(
repo_path
)
do
system
({
'GL_ID'
=>
gl_id
},
path
,
ref
,
oldrev
,
newrev
)
end
end
end
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