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
2dae0e18
Commit
2dae0e18
authored
Jan 04, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
web hooks scaffold started
parent
8d7aaf0e
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
85 additions
and
4 deletions
+85
-4
app/controllers/hooks_controller.rb
app/controllers/hooks_controller.rb
+43
-0
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+1
-1
app/controllers/repositories_controller.rb
app/controllers/repositories_controller.rb
+1
-1
app/models/user.rb
app/models/user.rb
+1
-0
app/models/web_hook.rb
app/models/web_hook.rb
+11
-0
app/views/hooks/index.html.haml
app/views/hooks/index.html.haml
+10
-0
app/workers/post_receive.rb
app/workers/post_receive.rb
+2
-0
config/routes.rb
config/routes.rb
+4
-2
spec/models/user_spec.rb
spec/models/user_spec.rb
+1
-0
spec/models/web_hook_spec.rb
spec/models/web_hook_spec.rb
+11
-0
No files found.
app/controllers/hooks_controller.rb
0 → 100644
View file @
2dae0e18
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
.
author
=
current_user
@hook
.
save
if
@hook
.
valid?
redirect_to
[
@project
,
@hook
]
else
respond_with
(
@hook
)
end
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/controllers/projects_controller.rb
View file @
2dae0e18
...
@@ -68,7 +68,7 @@ class ProjectsController < ApplicationController
...
@@ -68,7 +68,7 @@ class ProjectsController < ApplicationController
def
show
def
show
return
render
"projects/empty"
unless
@project
.
repo_exists?
&&
@project
.
has_commits?
return
render
"projects/empty"
unless
@project
.
repo_exists?
&&
@project
.
has_commits?
limit
=
(
params
[
:limit
]
||
2
0
).
to_i
limit
=
(
params
[
:limit
]
||
1
0
).
to_i
@activities
=
@project
.
cached_updates
(
limit
)
@activities
=
@project
.
cached_updates
(
limit
)
end
end
...
...
app/controllers/repositories_controller.rb
View file @
2dae0e18
...
@@ -9,7 +9,7 @@ class RepositoriesController < ApplicationController
...
@@ -9,7 +9,7 @@ class RepositoriesController < ApplicationController
layout
"project"
layout
"project"
def
show
def
show
@activities
=
@project
.
fresh_commits
(
2
0
)
@activities
=
@project
.
fresh_commits
(
1
0
)
end
end
def
branches
def
branches
...
...
app/models/user.rb
View file @
2dae0e18
...
@@ -82,5 +82,6 @@ end
...
@@ -82,5 +82,6 @@ end
# linkedin :string(255) default(""), not null
# linkedin :string(255) default(""), not null
# twitter :string(255) default(""), not null
# twitter :string(255) default(""), not null
# authentication_token :string(255)
# authentication_token :string(255)
# dark_scheme :boolean default(FALSE), not null
#
#
app/models/web_hook.rb
View file @
2dae0e18
...
@@ -18,3 +18,14 @@ class WebHook < ActiveRecord::Base
...
@@ -18,3 +18,14 @@ class WebHook < ActiveRecord::Base
# There was a problem calling this web hook, let's forget about it.
# There was a problem calling this web hook, let's forget about it.
end
end
end
end
# == Schema Information
#
# Table name: web_hooks
#
# id :integer not null, primary key
# url :string(255)
# project_id :integer
# created_at :datetime
# updated_at :datetime
#
app/views/hooks/index.html.haml
0 → 100644
View file @
2dae0e18
=
render
"repositories/head"
-
unless
@hooks
.
empty?
%div
.update-data.ui-box.ui-box-small
.data
-
@hooks
.
each
do
|
hook
|
%a
.update-item
{
:href
=>
project_hooks_path
(
@project
,
hook
)}
%span
.update-title
{
:style
=>
"margin-bottom:0px;"
}
=
hook
.
url
-
else
%h3
No hooks
app/workers/post_receive.rb
View file @
2dae0e18
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/routes.rb
View file @
2dae0e18
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,6 +83,8 @@ Gitlab::Application.routes.draw do
...
@@ -83,6 +83,8 @@ Gitlab::Application.routes.draw do
get
:commits
get
:commits
end
end
end
end
resources
:hooks
,
:only
=>
[
:index
,
:new
,
:create
,
:destroy
,
:show
]
resources
:snippets
resources
:snippets
resources
:commits
resources
:commits
resources
:team_members
resources
:team_members
...
...
spec/models/user_spec.rb
View file @
2dae0e18
...
@@ -65,5 +65,6 @@ end
...
@@ -65,5 +65,6 @@ end
# linkedin :string(255) default(""), not null
# linkedin :string(255) default(""), not null
# twitter :string(255) default(""), not null
# twitter :string(255) default(""), not null
# authentication_token :string(255)
# authentication_token :string(255)
# dark_scheme :boolean default(FALSE), not null
#
#
spec/models/web_hook_spec.rb
View file @
2dae0e18
...
@@ -52,3 +52,14 @@ describe WebHook do
...
@@ -52,3 +52,14 @@ describe WebHook do
end
end
end
end
end
end
# == Schema Information
#
# Table name: web_hooks
#
# id :integer not null, primary key
# url :string(255)
# project_id :integer
# created_at :datetime
# updated_at :datetime
#
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