Skip to content

Commit 473445c

Browse files
committed
complete hooks for post receive
1 parent 57ac5fe commit 473445c

7 files changed

+64
-5
lines changed

.foreman

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
port: 9999
1+
port: 3000

app/controllers/projects_controller.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def update
6868

6969
def show
7070
return render "projects/empty" unless @project.repo_exists? && @project.has_commits?
71-
limit = (params[:limit] || 10).to_i
71+
limit = (params[:limit] || 20).to_i
7272
@activities = @project.cached_updates(limit)
7373
end
7474

app/controllers/repositories_controller.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class RepositoriesController < ApplicationController
99
layout "project"
1010

1111
def show
12-
@activities = @project.fresh_commits(10)
12+
@activities = @project.fresh_commits(20)
1313
end
1414

1515
def branches

app/views/hooks/_data_ex.html.erb

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<% data_ex_str = <<eos
2+
{
3+
:before => "95790bf891e76fee5e1747ab589903a6a1f80f22",
4+
:after => "da1560886d4f094c3e6c9ef40349f7d38b5d27d7",
5+
:ref => "refs/heads/master",
6+
:repository => {
7+
:name => "Diaspora",
8+
:url => "localhost/diaspora",
9+
:description => "",
10+
:homepage => "localhost/diaspora",
11+
:private => true
12+
},
13+
:commits => [
14+
[0] {
15+
:id => "450d0de7532f8b663b9c5cce183b...",
16+
:message => "Update Catalan translation to e38cb41.",
17+
:timestamp => "2011-12-12T14:27:31+02:00",
18+
:url => "http://localhost/diaspora/commits/450d0de7532f...",
19+
:author => {
20+
:name => "Jordi Mallach",
21+
:email => "[email protected]"
22+
}
23+
},
24+
25+
....
26+
27+
[3] {
28+
:id => "da1560886d4f094c3e6c9ef40349...",
29+
:message => "fixed readme",
30+
:timestamp => "2012-01-03T23:36:29+02:00",
31+
:url => "http://localhost/diaspora/commits/da1560886d...",
32+
:author => {
33+
:name => "gitlab dev user",
34+
:email => "gitlabdev@dv6700.(none)"
35+
}
36+
}
37+
]
38+
}
39+
eos
40+
%>
41+
<% js_lexer = Pygments::Lexer[:js] %>
42+
<%= raw js_lexer.highlight(data_ex_str) %>

app/views/hooks/index.html.haml

+14
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
= render "repositories/head"
2+
3+
4+
5+
26
.right= link_to "Add new", new_project_hook_path(@project), :class => "grey-button append-bottom-10"
37
- unless @hooks.empty?
48
%div.update-data.ui-box.ui-box-small
@@ -14,3 +18,13 @@
1418
- else
1519
%h3 No hooks
1620

21+
.clear
22+
%h3 Help
23+
%p
24+
Post receive hooks. For now only POST request allowed. We send some data with request. Example below
25+
26+
.view_file
27+
.view_file_header
28+
%strong POST data passed
29+
.data.no-padding
30+
= render "data_ex"

app/views/hooks/show.html.haml

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
= render "repositories/head"
2-
%h3= @hook.url
2+
%h3
3+
%span.commit.tag POST
4+
= @hook.url
5+
36

47
- if can? current_user, :admin_project, @project
58
.merge-tabs

config/database.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ test:
2020

2121
production:
2222
adapter: sqlite3
23-
database: db/production.sqlite3
23+
database: db/development.sqlite3
2424
pool: 5
2525
timeout: 5000

0 commit comments

Comments
 (0)