Skip to content

Commit

Permalink
complete hooks for post receive
Browse files Browse the repository at this point in the history
  • Loading branch information
dzaporozhets committed Jan 8, 2012
1 parent 57ac5fe commit 473445c
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .foreman
Original file line number Diff line number Diff line change
@@ -1 +1 @@
port: 9999
port: 3000
2 changes: 1 addition & 1 deletion app/controllers/projects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def update

def show
return render "projects/empty" unless @project.repo_exists? && @project.has_commits?
limit = (params[:limit] || 10).to_i
limit = (params[:limit] || 20).to_i
@activities = @project.cached_updates(limit)
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/repositories_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class RepositoriesController < ApplicationController
layout "project"

def show
@activities = @project.fresh_commits(10)
@activities = @project.fresh_commits(20)
end

def branches
Expand Down
42 changes: 42 additions & 0 deletions app/views/hooks/_data_ex.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<% 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 => "[email protected]"
}
},

....

[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) %>
14 changes: 14 additions & 0 deletions app/views/hooks/index.html.haml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
= 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
Expand All @@ -14,3 +18,13 @@
- 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"
5 changes: 4 additions & 1 deletion app/views/hooks/show.html.haml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
= render "repositories/head"
%h3= @hook.url
%h3
%span.commit.tag POST
= @hook.url


- if can? current_user, :admin_project, @project
.merge-tabs
Expand Down
2 changes: 1 addition & 1 deletion config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ test:

production:
adapter: sqlite3
database: db/production.sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000

0 comments on commit 473445c

Please sign in to comment.