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
Tatuya Kamada
gitlab-ce
Commits
bc0155fb
Commit
bc0155fb
authored
Dec 13, 2011
by
Ariejan de Vroom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
First attempt at a post-receive hook that posts directly to Resque
parent
1c9b9b7a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
14 deletions
+30
-14
app/models/repository.rb
app/models/repository.rb
+11
-0
app/workers/post_receive.rb
app/workers/post_receive.rb
+5
-0
db/schema.rb
db/schema.rb
+0
-12
lib/gitlabhq/gitolite.rb
lib/gitlabhq/gitolite.rb
+2
-2
lib/post-receive-hook
lib/post-receive-hook
+12
-0
No files found.
app/models/repository.rb
View file @
bc0155fb
...
@@ -31,6 +31,17 @@ class Repository
...
@@ -31,6 +31,17 @@ class Repository
project
.
id
project
.
id
end
end
# repo.update_hook('post-receive', File.read('some-hook'))
def
update_hook
(
name
,
content
)
hook_file
=
File
.
join
(
project
.
path_to_repo
,
'hooks'
,
name
)
File
.
open
(
hook_file
,
'w'
)
do
|
f
|
f
.
write
(
content
)
end
File
.
chmod
(
0775
,
hook_file
)
end
def
repo
def
repo
@repo
||=
Grit
::
Repo
.
new
(
project
.
path_to_repo
)
@repo
||=
Grit
::
Repo
.
new
(
project
.
path_to_repo
)
end
end
...
...
app/workers/post_receive.rb
0 → 100644
View file @
bc0155fb
class
PostReceive
def
self
.
perform
(
reponame
,
oldrev
,
newrev
,
ref
)
puts
"[
#{
reponame
}
]
#{
oldrev
}
=>
#{
newrev
}
(
#{
ref
}
)"
end
end
db/schema.rb
View file @
bc0155fb
...
@@ -13,18 +13,6 @@
...
@@ -13,18 +13,6 @@
ActiveRecord
::
Schema
.
define
(
:version
=>
20111207211728
)
do
ActiveRecord
::
Schema
.
define
(
:version
=>
20111207211728
)
do
create_table
"features"
,
:force
=>
true
do
|
t
|
t
.
string
"name"
t
.
string
"branch_name"
t
.
integer
"assignee_id"
t
.
integer
"author_id"
t
.
integer
"project_id"
t
.
datetime
"created_at"
t
.
datetime
"updated_at"
t
.
string
"version"
t
.
integer
"status"
,
:default
=>
0
,
:null
=>
false
end
create_table
"issues"
,
:force
=>
true
do
|
t
|
create_table
"issues"
,
:force
=>
true
do
|
t
|
t
.
string
"title"
t
.
string
"title"
t
.
integer
"assignee_id"
t
.
integer
"assignee_id"
...
...
lib/gitlabhq/gitolite.rb
View file @
bc0155fb
...
@@ -43,14 +43,14 @@ module Gitlabhq
...
@@ -43,14 +43,14 @@ module Gitlabhq
def
destroy_project
(
project
)
def
destroy_project
(
project
)
FileUtils
.
rm_rf
(
project
.
path_to_repo
)
FileUtils
.
rm_rf
(
project
.
path_to_repo
)
ga_repo
=
::
Gitolite
::
GitoliteAdmin
.
new
(
File
.
join
(
@local_dir
,
'gitolite'
))
ga_repo
=
::
Gitolite
::
GitoliteAdmin
.
new
(
File
.
join
(
@local_dir
,
'gitolite'
))
conf
=
ga_repo
.
config
conf
=
ga_repo
.
config
conf
.
rm_repo
(
project
.
path
)
conf
.
rm_repo
(
project
.
path
)
ga_repo
.
save
ga_repo
.
save
end
end
#update or create
#update or create
def
update_keys
(
user
,
key
)
def
update_keys
(
user
,
key
)
File
.
open
(
File
.
join
(
@local_dir
,
'gitolite/keydir'
,
"
#{
user
}
.pub"
),
'w'
)
{
|
f
|
f
.
write
(
key
.
gsub
(
/\n/
,
''
))
}
File
.
open
(
File
.
join
(
@local_dir
,
'gitolite/keydir'
,
"
#{
user
}
.pub"
),
'w'
)
{
|
f
|
f
.
write
(
key
.
gsub
(
/\n/
,
''
))
}
end
end
...
...
lib/post-receive-hook
0 → 100755
View file @
bc0155fb
#!/bin/bash
# This file was placed here by Gitlab. It makes sure that your pushed commits
# will be processed properly.
while
read
oldrev newrev ref
do
# For every branch or tag that was pushed, create a Resque job in redis.
pwd
=
`
pwd
`
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
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