BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
15a03e1d
Commit
15a03e1d
authored
Jul 02, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1023 from SaitoWu/feature/https
Feature/https
parents
f464d4c9
40134016
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
11 deletions
+18
-11
git_push.rb
app/roles/git_push.rb
+5
-7
post_receive.rb
app/workers/post_receive.rb
+7
-3
grack_auth.rb
config/initializers/grack_auth.rb
+5
-0
routes.rb
config/routes.rb
+1
-1
No files found.
app/roles/git_push.rb
View file @
15a03e1d
...
@@ -21,7 +21,7 @@ module GitPush
...
@@ -21,7 +21,7 @@ module GitPush
# Close merge requests
# Close merge requests
mrs
=
self
.
merge_requests
.
opened
.
where
(
:target_branch
=>
branch_name
).
all
mrs
=
self
.
merge_requests
.
opened
.
where
(
:target_branch
=>
branch_name
).
all
mrs
=
mrs
.
select
(
&
:last_commit
).
select
{
|
mr
|
c_ids
.
include?
(
mr
.
last_commit
.
id
)
}
mrs
=
mrs
.
select
(
&
:last_commit
).
select
{
|
mr
|
c_ids
.
include?
(
mr
.
last_commit
.
id
)
}
mrs
.
each
{
|
merge_request
|
merge_request
.
merge!
(
user
.
id
)
}
mrs
.
each
{
|
merge_request
|
merge_request
.
merge!
(
user
.
id
)
}
true
true
...
@@ -65,7 +65,7 @@ module GitPush
...
@@ -65,7 +65,7 @@ module GitPush
total_commits_count:
push_commits_count
total_commits_count:
push_commits_count
}
}
# For perfomance purposes maximum 20 latest commits
# For perfomance purposes maximum 20 latest commits
# will be passed as post receive hook data.
# will be passed as post receive hook data.
#
#
push_commits_limited
.
each
do
|
commit
|
push_commits_limited
.
each
do
|
commit
|
...
@@ -86,16 +86,14 @@ module GitPush
...
@@ -86,16 +86,14 @@ module GitPush
# This method will be called after each post receive
# This method will be called after each post receive
# and only if
autor_key_id present in gitlab.
# and only if
user present in gitlab.
# All callbacks for post receive should be placed here
# All callbacks for post receive should be placed here
#
#
def
trigger_post_receive
(
oldrev
,
newrev
,
ref
,
author_key_id
)
def
trigger_post_receive
(
oldrev
,
newrev
,
ref
,
user
)
user
=
Key
.
find_by_identifier
(
author_key_id
).
user
# Create push event
# Create push event
self
.
observe_push
(
oldrev
,
newrev
,
ref
,
user
)
self
.
observe_push
(
oldrev
,
newrev
,
ref
,
user
)
# Close merged MR
# Close merged MR
self
.
update_merge_requests
(
oldrev
,
newrev
,
ref
,
user
)
self
.
update_merge_requests
(
oldrev
,
newrev
,
ref
,
user
)
# Execute web hooks
# Execute web hooks
...
...
app/workers/post_receive.rb
View file @
15a03e1d
class
PostReceive
class
PostReceive
@queue
=
:post_receive
@queue
=
:post_receive
def
self
.
perform
(
reponame
,
oldrev
,
newrev
,
ref
,
author_key_id
)
def
self
.
perform
(
reponame
,
oldrev
,
newrev
,
ref
,
identifier
)
project
=
Project
.
find_by_path
(
reponame
)
project
=
Project
.
find_by_path
(
reponame
)
return
false
if
project
.
nil?
return
false
if
project
.
nil?
# Ignore push from non-gitlab users
# Ignore push from non-gitlab users
return
false
unless
Key
.
find_by_identifier
(
author_key_id
)
if
/^[A-Z0-9._%a-z\-]+@(?:[A-Z0-9a-z\-]+\.)+[A-Za-z]{2,4}$/
.
match
(
identifier
)
return
false
unless
user
=
User
.
find_by_email
(
identifier
)
else
return
false
unless
user
=
Key
.
find_by_identifier
(
identifier
).
try
(
:user
)
end
project
.
trigger_post_receive
(
oldrev
,
newrev
,
ref
,
author_key_id
)
project
.
trigger_post_receive
(
oldrev
,
newrev
,
ref
,
user
)
end
end
end
end
config/initializers/grack_auth.rb
View file @
15a03e1d
...
@@ -7,6 +7,11 @@ module Grack
...
@@ -7,6 +7,11 @@ module Grack
user
=
User
.
find_by_email
(
email
)
user
=
User
.
find_by_email
(
email
)
return
false
unless
user
.
try
(
:valid_password?
,
password
)
return
false
unless
user
.
try
(
:valid_password?
,
password
)
# Set GL_USER env variable
ENV
[
'GL_USER'
]
=
email
# Pass Gitolite update hook
ENV
[
'GL_BYPASS_UPDATE_HOOK'
]
=
"true"
# Need this patch because the rails mount
# Need this patch because the rails mount
@env
[
'PATH_INFO'
]
=
@env
[
'REQUEST_PATH'
]
@env
[
'PATH_INFO'
]
=
@env
[
'REQUEST_PATH'
]
...
...
config/routes.rb
View file @
15a03e1d
...
@@ -18,7 +18,7 @@ Gitlab::Application.routes.draw do
...
@@ -18,7 +18,7 @@ Gitlab::Application.routes.draw do
project_root:
GIT_HOST
[
'base_path'
],
project_root:
GIT_HOST
[
'base_path'
],
upload_pack:
GIT_HOST
[
'upload_pack'
],
upload_pack:
GIT_HOST
[
'upload_pack'
],
receive_pack:
GIT_HOST
[
'receive_pack'
]
receive_pack:
GIT_HOST
[
'receive_pack'
]
}),
at:
'/:path'
,
constraints:
{
path:
/[\w-]+
.git*
/
}
}),
at:
'/:path'
,
constraints:
{
path:
/[\w-]+
\.git
/
}
#
#
# Help
# Help
...
...
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