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
Boxiang Sun
gitlab-ce
Commits
7b0cd969
Commit
7b0cd969
authored
Jan 08, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'web_hooks_scaffold'
parents
a3efa430
473445c7
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
172 additions
and
6 deletions
+172
-6
.foreman
.foreman
+1
-0
Procfile
Procfile
+2
-0
app/assets/stylesheets/projects.css.scss
app/assets/stylesheets/projects.css.scss
+7
-0
app/controllers/hooks_controller.rb
app/controllers/hooks_controller.rb
+51
-0
app/helpers/projects_helper.rb
app/helpers/projects_helper.rb
+2
-1
app/views/hooks/_data_ex.html.erb
app/views/hooks/_data_ex.html.erb
+42
-0
app/views/hooks/index.html.haml
app/views/hooks/index.html.haml
+30
-0
app/views/hooks/new.html.haml
app/views/hooks/new.html.haml
+13
-0
app/views/hooks/show.html.haml
app/views/hooks/show.html.haml
+11
-0
app/views/repositories/_head.html.haml
app/views/repositories/_head.html.haml
+1
-1
app/workers/post_receive.rb
app/workers/post_receive.rb
+2
-0
config/database.yml
config/database.yml
+1
-1
config/routes.rb
config/routes.rb
+8
-2
lib/post-receive-hook
lib/post-receive-hook
+1
-1
No files found.
.foreman
0 → 100644
View file @
7b0cd969
port: 3000
Procfile
0 → 100644
View file @
7b0cd969
web: bundle exec rails s -p $PORT
worker: bundle exec rake environment resque:work QUEUE=*
app/assets/stylesheets/projects.css.scss
View file @
7b0cd969
...
@@ -181,6 +181,13 @@ input.ssh_project_url {
...
@@ -181,6 +181,13 @@ input.ssh_project_url {
}
}
}
}
.text_field
{
width
:
400px
;
padding
:
8px
;
font-size
:
14px
;
@include
round-borders-all
(
4px
);
}
.input_button
{
.input_button
{
padding
:
8px
;
padding
:
8px
;
font-size
:
14px
;
font-size
:
14px
;
...
...
app/controllers/hooks_controller.rb
0 → 100644
View file @
7b0cd969
class
HooksController
<
ApplicationController
before_filter
:authenticate_user!
before_filter
:project
layout
"project"
# Authorize
before_filter
:add_project_abilities
before_filter
:authorize_read_project!
before_filter
:authorize_admin_project!
,
:only
=>
[
:new
,
:create
,
:destroy
]
respond_to
:html
def
index
@hooks
=
@project
.
web_hooks
end
def
new
@hook
=
@project
.
web_hooks
.
new
end
def
create
@hook
=
@project
.
web_hooks
.
new
(
params
[
:hook
])
@hook
.
save
if
@hook
.
valid?
redirect_to
project_hook_path
(
@project
,
@hook
)
else
render
:new
end
end
def
test
@hook
=
@project
.
web_hooks
.
find
(
params
[
:id
])
commits
=
@project
.
commits
(
@project
.
default_branch
,
nil
,
3
)
data
=
@project
.
web_hook_data
(
commits
.
last
.
id
,
commits
.
first
.
id
,
"refs/heads/
#{
@project
.
default_branch
}
"
)
@hook
.
execute
(
data
)
redirect_to
:back
end
def
show
@hook
=
@project
.
web_hooks
.
find
(
params
[
:id
])
end
def
destroy
@hook
=
@project
.
web_hooks
.
find
(
params
[
:id
])
@hook
.
destroy
redirect_to
project_hooks_path
(
@project
)
end
end
app/helpers/projects_helper.rb
View file @
7b0cd969
...
@@ -35,7 +35,8 @@ module ProjectsHelper
...
@@ -35,7 +35,8 @@ module ProjectsHelper
end
end
def
repository_tab_class
def
repository_tab_class
if
controller
.
controller_name
==
"repositories"
if
controller
.
controller_name
==
"repositories"
||
controller
.
controller_name
==
"hooks"
"current"
"current"
end
end
end
end
...
...
app/views/hooks/_data_ex.html.erb
0 → 100644
View file @
7b0cd969
<%
data_ex_str
=
<<
eos
{
:before => "95790bf891e76fee5e1747ab589903a6a1f80f22",
:after => "da1560886d4f094c3e6c9ef40349f7d38b5d27d7",
:ref => "refs/heads/master",
:repository => {
:name => "Diaspora",
:url => "localhost/diaspora",
:description => "",
:homepage => "localhost/diaspora",
:private => true
},
:commits => [
[0] {
:id => "450d0de7532f8b663b9c5cce183b...",
:message => "Update Catalan translation to e38cb41.",
:timestamp => "2011-12-12T14:27:31+02:00",
:url => "http://localhost/diaspora/commits/450d0de7532f...",
:author => {
:name => "Jordi Mallach",
:email => "jordi@softcatala.org"
}
},
....
[3] {
:id => "da1560886d4f094c3e6c9ef40349...",
:message => "fixed readme",
:timestamp => "2012-01-03T23:36:29+02:00",
:url => "http://localhost/diaspora/commits/da1560886d...",
:author => {
:name => "gitlab dev user",
:email => "gitlabdev@dv6700.(none)"
}
}
]
}
eos
%>
<%
js_lexer
=
Pygments
::
Lexer
[
:js
]
%>
<%=
raw
js_lexer
.
highlight
(
data_ex_str
)
%>
app/views/hooks/index.html.haml
0 → 100644
View file @
7b0cd969
=
render
"repositories/head"
.right
=
link_to
"Add new"
,
new_project_hook_path
(
@project
),
:class
=>
"grey-button append-bottom-10"
-
unless
@hooks
.
empty?
%div
.update-data.ui-box.ui-box-small
.data
-
@hooks
.
each
do
|
hook
|
%a
.update-item
{
:href
=>
project_hook_path
(
@project
,
hook
)}
%span
.update-title
{
:style
=>
"margin-bottom:0px;"
}
=
hook
.
url
%span
.update-author.right
Added
=
time_ago_in_words
(
hook
.
created_at
)
ago
-
else
%h3
No hooks
.clear
%h3
Help
%p
Post receive hooks. For now only POST request allowed. We send some data with request. Example below
.view_file
.view_file_header
%strong
POST data passed
.data.no-padding
=
render
"data_ex"
app/views/hooks/new.html.haml
0 → 100644
View file @
7b0cd969
=
render
"repositories/head"
=
form_for
[
@project
,
@hook
],
:as
=>
:hook
,
:url
=>
project_hooks_path
(
@project
)
do
|
f
|
-
if
@hook
.
errors
.
any?
%ul
-
@hook
.
errors
.
full_messages
.
each
do
|
msg
|
%li
=
msg
=
f
.
label
:url
,
"URL:"
=
f
.
text_field
:url
,
:class
=>
"text_field"
.clear
%br
.merge-tabs
=
f
.
submit
"Save"
,
:class
=>
"grey-button"
app/views/hooks/show.html.haml
0 → 100644
View file @
7b0cd969
=
render
"repositories/head"
%h3
%span
.commit.tag
POST
=
@hook
.
url
-
if
can?
current_user
,
:admin_project
,
@project
.merge-tabs
=
link_to
'Test Hook'
,
test_project_hook_path
(
@project
,
@hook
),
:class
=>
"grey-button"
.right
=
link_to
'Remove'
,
project_hook_path
(
@project
,
@hook
),
:confirm
=>
'Are you sure?'
,
:method
=>
:delete
,
:class
=>
"red-button"
app/views/repositories/_head.html.haml
View file @
7b0cd969
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
=
link_to
tags_project_repository_path
(
@project
),
:class
=>
"tab
#{
'active'
if
current_page?
(
tags_project_repository_path
(
@project
))
}
"
do
=
link_to
tags_project_repository_path
(
@project
),
:class
=>
"tab
#{
'active'
if
current_page?
(
tags_project_repository_path
(
@project
))
}
"
do
%span
%span
Tags
Tags
-#= link_to "#", :class => "tab
" do
=
link_to
project_hooks_path
,
:class
=>
"tab
#{
'active'
if
controller
.
controller_name
==
"hooks"
}
"
do
%span
%span
Hooks
Hooks
-#= link_to "#", :class => "tab" do
-#= link_to "#", :class => "tab" do
...
...
app/workers/post_receive.rb
View file @
7b0cd969
class
PostReceive
class
PostReceive
@queue
=
:post_receive
def
self
.
perform
(
reponame
,
oldrev
,
newrev
,
ref
)
def
self
.
perform
(
reponame
,
oldrev
,
newrev
,
ref
)
project
=
Project
.
find_by_path
(
reponame
)
project
=
Project
.
find_by_path
(
reponame
)
return
false
if
project
.
nil?
return
false
if
project
.
nil?
...
...
config/database.yml
View file @
7b0cd969
...
@@ -20,6 +20,6 @@ test:
...
@@ -20,6 +20,6 @@ test:
production
:
production
:
adapter
:
sqlite3
adapter
:
sqlite3
database
:
db/
production
.sqlite3
database
:
db/
development
.sqlite3
pool
:
5
pool
:
5
timeout
:
5000
timeout
:
5000
config/routes.rb
View file @
7b0cd969
Gitlab
::
Application
.
routes
.
draw
do
Gitlab
::
Application
.
routes
.
draw
do
# Optionally, enable Resque here
# Optionally, enable Resque here
#
require 'resque/server'
require
'resque/server'
#
mount Resque::Server.new, at: '/info/resque'
mount
Resque
::
Server
.
new
,
at:
'/info/resque'
get
'tags'
=>
'tags#index'
get
'tags'
=>
'tags#index'
get
'tags/:tag'
=>
'projects#index'
get
'tags/:tag'
=>
'projects#index'
...
@@ -83,7 +83,13 @@ Gitlab::Application.routes.draw do
...
@@ -83,7 +83,13 @@ Gitlab::Application.routes.draw do
get
:commits
get
:commits
end
end
end
end
resources
:snippets
resources
:snippets
resources
:hooks
,
:only
=>
[
:index
,
:new
,
:create
,
:destroy
,
:show
]
do
member
do
get
:test
end
end
resources
:commits
resources
:commits
resources
:team_members
resources
:team_members
resources
:issues
do
resources
:issues
do
...
...
lib/post-receive-hook
View file @
7b0cd969
...
@@ -8,5 +8,5 @@ do
...
@@ -8,5 +8,5 @@ do
# For every branch or tag that was pushed, create a Resque job in redis.
# For every branch or tag that was pushed, create a Resque job in redis.
pwd
=
`
pwd
`
pwd
=
`
pwd
`
reponame
=
`
basename
"
$pwd
"
|
cut
-d
.
-f1
`
reponame
=
`
basename
"
$pwd
"
|
cut
-d
.
-f1
`
env
-i
redis-cli rpush
"resque:queue:post
-
receive"
"{
\"
class
\"
:
\"
PostReceive
\"
,
\"
args
\"
:[
\"
$reponame
\"
,
\"
$oldrev
\"
,
\"
$newrev
\"
,
\"
$ref
\"
]}"
>
/dev/null 2>&1
env
-i
redis-cli rpush
"resque:queue:post
_
receive"
"{
\"
class
\"
:
\"
PostReceive
\"
,
\"
args
\"
:[
\"
$reponame
\"
,
\"
$oldrev
\"
,
\"
$newrev
\"
,
\"
$ref
\"
]}"
>
/dev/null 2>&1
done
done
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