implements protected branches to smart http protocal
This commit is contained in:
parent
7f44599ed0
commit
8db947bcfe
1 changed files with 19 additions and 4 deletions
|
@ -18,14 +18,29 @@ module Grack
|
||||||
elsif @env['REQUEST_METHOD'] == 'POST'
|
elsif @env['REQUEST_METHOD'] == 'POST'
|
||||||
if @env['REQUEST_URI'].end_with?('git-upload-pack')
|
if @env['REQUEST_URI'].end_with?('git-upload-pack')
|
||||||
return project.dev_access_for?(user)
|
return project.dev_access_for?(user)
|
||||||
elsif @env['REQUEST_URI'].end_with?('git-upload-pack')
|
elsif @env['REQUEST_URI'].end_with?('git-receive-pack')
|
||||||
#TODO master branch protection
|
if project.protected_branches.map(&:name).include?(current_ref)
|
||||||
return project.dev_access_for?(user)
|
project.master_access_for?(user)
|
||||||
|
else
|
||||||
|
project.dev_access_for?(user)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
false
|
||||||
|
end
|
||||||
|
end# valid?
|
||||||
|
|
||||||
|
def current_ref
|
||||||
|
if @env["HTTP_CONTENT_ENCODING"] =~ /gzip/
|
||||||
|
input = Zlib::GzipReader.new(@request.body).string
|
||||||
|
else
|
||||||
|
input = @request.body.string
|
||||||
end
|
end
|
||||||
|
|
||||||
end# valid?
|
oldrev, newrev, ref = input.split(' ')
|
||||||
|
/refs\/heads\/([\w-]+)/.match(ref).to_a.last
|
||||||
|
end
|
||||||
end# Auth
|
end# Auth
|
||||||
end# Grack
|
end# Grack
|
||||||
|
|
Loading…
Reference in a new issue