Merge branch 'develop' of 10.0.47.245:/home/trustie2 into develop

This commit is contained in:
zhangyang 2013-08-19 19:54:34 +08:00
commit 775dbb313c
31 changed files with 516 additions and 37 deletions

View File

@ -15,6 +15,7 @@ class BidsController < ApplicationController
@bids = @bids.like(params[:name]) if params[:name].present? @bids = @bids.like(params[:name]) if params[:name].present?
@bid_count = @bids.count @bid_count = @bids.count
@bid_pages = Paginator.new @bid_count, @limit, params['page'] @bid_pages = Paginator.new @bid_count, @limit, params['page']
@offset ||= @bid_pages.reverse_offset @offset ||= @bid_pages.reverse_offset
#@bids = @bids.offset(@offset).limit(@limit).all.reverse #@bids = @bids.offset(@offset).limit(@limit).all.reverse
unless @offset == 0 unless @offset == 0

View File

@ -76,6 +76,8 @@ class RepositoriesController < ApplicationController
@repository_name=User.current.login.to_s+"/"+params[:repository][:identifier]+".git" @repository_name=User.current.login.to_s+"/"+params[:repository][:identifier]+".git"
@project_path=@root_path+"htdocs/"+@repository_name @project_path=@root_path+"htdocs/"+@repository_name
@repository_tag=params[:repository][:upassword] @repository_tag=params[:repository][:upassword]
@repo_name=User.current.login.to_s+"-"+params[:repository][:identifier]
@middle=User.current.login.to_s+"-"+params[:repository][:identifier]+"-write:"
attrs = pickup_extra_info attrs = pickup_extra_info
if((@repository_tag!="")&&params[:repository_scm]=="Git") if((@repository_tag!="")&&params[:repository_scm]=="Git")
params[:repository][:url]=@project_path params[:repository][:url]=@project_path
@ -91,23 +93,26 @@ class RepositoriesController < ApplicationController
@repository.project = @project @repository.project = @project
if request.post? && @repository.save if request.post? && @repository.save
if(params[:repository_scm]=="Git") if(params[:repository_scm]=="Git")
system "htpasswd -mb "+@root_path+"user.passwd "+User.current.login.to_s+" "+@repository_tag system "htpasswd -mb "+@root_path+" "+@repo_name+" "+@repository_tag
system "echo -e '\n"+User.current.login.to_s+"-"+params[:repository][:identifier]+"-write:"+ logger.info "htpasswd -mb "+@root_path+" "+@repo_name+" "+@repository_tag+create_passwd
" "+User.current.login.to_s+"' >> "+@root_path+"group.passwd" system "echo -e '\n"+@repo_name+"-write:"+
" "+@repo_name+"' >> "+@root_path+"group.passwd"
system "mkdir "+@root_path+"htdocs/"+User.current.login.to_s system "mkdir "+@root_path+"htdocs/"+User.current.login.to_s
system "git init --bare "+@project_path system "git init --bare "+@project_path
system "mv "+@project_path+"/hooks/post-update{.sample,}" system "mv "+@project_path+"/hooks/post-update{.sample,}"
system "chmod a+x "+@project_path+"/hooks/post-update" system "chmod a+x "+@project_path+"/hooks/post-update"
system "echo -e 'Allow from all \n Order Deny,Allow \n "+ system "echo -e 'Allow from all \n Order Deny,Allow \n "+
"<Limit PUT POST DELETE PROPPATCH MKCOL COPY MOVE LOCK UNLOCK> \n"+ "<Limit PUT POST DELETE PROPPATCH MKCOL COPY MOVE LOCK UNLOCK> \n"+
"Require group "+User.current.login.to_s+"-"+params[:repository][:identifier]+"-write \n "+ "Require group "+@repo_name+"-write \n "+
"</Limit> \n ' >> "+ "</Limit> \n ' >> "+
@root_path+"htdocs/"+ @repository_name+"/.htaccess" @root_path+"htdocs/"+ @repository_name+"/.htaccess"
system "cd "+@project_path+" ;git update-server-info"
puts "before ======================================================================" # if(create_repo_file&&create_passwd&&create_group&&init_repository&&add_privilege&&init_server_info)
puts system "cd "+@project_path+" ;git update-server-info" # else
flag = system "cd "+@project_path+" ;git update-server-info" # logger.info "An error occured when authenticating "+"create passwd"+@creat_passwd+"create_group"+
puts "after flag:#{flag} ======================================================================" # crate_group+"create repository file "+create_repo_file+"init repository"+init_repostory+
# "aad privilege to rpository"+add_privilege+"init server infos"+init_server_info
# end
@repository.update_attributes(:login => User.current.login.to_s) @repository.update_attributes(:login => User.current.login.to_s)
end end
redirect_to settings_project_path(@project, :tab => 'repositories') redirect_to settings_project_path(@project, :tab => 'repositories')
@ -171,10 +176,14 @@ class RepositoriesController < ApplicationController
@repository.destroy if request.delete? @repository.destroy if request.delete?
redirect_to settings_project_path(@project, :tab => 'repositories') redirect_to settings_project_path(@project, :tab => 'repositories')
if(@repository.type=="Repository::Git") if(@repository.type=="Repository::Git")
puts "before destroy system cmd =======================================" system "sed -i /"+@repo_name+"/{d} "+@root_path+"user.passwd"
puts "rm -r "+@root_path+@repository_name system "sed -i /"+@middle+"/{d} "+@root_path+"group.passwd"
flag = system "rm -r "+@root_path+"htdocs/"+@repository_name system "rm -r "+@root_path+"htdocs/"+@repository_name
puts "after destroy system cmd :#{flag} =======================================" # if(@sed_user&&@sed_group&&@remove)
# else
# logger.info "An error occured when destory the repository"+"delete form passwd: \n"+
# @sed_user+"delete from group"+@sed_group+"delete from file"+@remove
# end
end end
end end

View File

@ -7,6 +7,7 @@ class TagsController < ApplicationController
include UsersHelper include UsersHelper
include BidsHelper include BidsHelper
include ActsAsTaggableOn::TagsHelper include ActsAsTaggableOn::TagsHelper
helper :projects
$selected_tags = Array.new $selected_tags = Array.new
$related_tags = Array.new $related_tags = Array.new
@ -21,23 +22,56 @@ class TagsController < ApplicationController
@users_tags_num = User.tag_counts.size @users_tags_num = User.tag_counts.size
@bids_tags_num = Bid.tag_counts.size @bids_tags_num = Bid.tag_counts.size
@issues_results = get_issues_by_tag($selected_tags) # 这里为了提高系统的响应速度 把搜索结果放到case中去了
@projects_results = get_projects_by_tag($selected_tags) @users_results = nil
@users_results = get_users_by_tag($selected_tags) @projects_results = nil
@bids_results = get_bids_by_tag($selected_tags) @issues_results = nil
@bids_results = nil
@obj_pages = nil
@obj_id = params[:obj_id] @obj_id = params[:obj_id]
@obj_flag = params[:object_flag] @obj_flag = params[:object_flag]
@numbers = Setting.tags_show_search_results
case @obj_flag case @obj_flag
when '1' then when '1' then
@users_results = get_users_by_tag($selected_tags)
@obj = User.find_by_id(@obj_id) @obj = User.find_by_id(@obj_id)
@offset, @limit = api_offset_and_limit({:limit => @numbers})
@project_count = @users_results.count
@obj_pages = Paginator.new @project_count, @limit, params['page']
@offset ||= @obj_pages.offset
@users_results = @users_results.offset(@offset).limit(@limit).all
when '2' then when '2' then
@projects_results = get_projects_by_tag($selected_tags)
@obj = Project.find_by_id(@obj_id) @obj = Project.find_by_id(@obj_id)
@offset, @limit = api_offset_and_limit({:limit => @numbers})
@project_count = @projects_results.count
@obj_pages = Paginator.new @project_count, @limit, params['page']
@offset ||= @obj_pages.offset
@projects_results = @projects_results.offset(@offset).limit(@limit).order('lft').all
when '3' then when '3' then
@issues_results = get_issues_by_tag($selected_tags)
@obj = Issue.find_by_id(@obj_id) @obj = Issue.find_by_id(@obj_id)
@offset, @limit = api_offset_and_limit({:limit => @numbers})
@project_count = @issues_results.count
@obj_pages = Paginator.new @project_count, @limit, params['page']
@offset ||= @obj_pages.offset
@issues_results = @issues_results.offset(@offset).limit(@limit).all
when '4' when '4'
@bids_results = get_bids_by_tag($selected_tags)
@obj = Bid.find_by_id(@obj_id) @obj = Bid.find_by_id(@obj_id)
@offset, @limit = api_offset_and_limit({:limit => @numbers})
@project_count = @bids_results.count
@obj_pages = Paginator.new @project_count, @limit, params['page']
@offset ||= @obj_pages.offset
@bids_results = @bids_results.offset(@offset).limit(@limit).all
else else
@obj = nil @obj = nil
end end
@ -83,4 +117,12 @@ class TagsController < ApplicationController
end end
def for_pagination(results)
@offset, @limit = api_offset_and_limit({:limit => 2})
@project_count = results.count
@obj_pages = Paginator.new @project_count, @limit, params['page']
@offset ||= @obj_pages.offset
results = results.offset(@offset).limit(@limit).order('lft').all
end
end end

View File

@ -1311,6 +1311,9 @@ module ApplicationHelper
def show_watcher_profile(obj) def show_watcher_profile(obj)
count = 0 count = 0
html = '' html = ''
if User.watched_by(obj.id).count == 0
html << (content_tag "span", l(:label_no_current_watchers))
end
for user in User.watched_by(obj.id) for user in User.watched_by(obj.id)
html << (link_to image_tag(url_to_avatar(user), :class => "avatar"), user_path(user), :class => "avatar", :title => "#{user.name}") html << (link_to image_tag(url_to_avatar(user), :class => "avatar"), user_path(user), :class => "avatar", :title => "#{user.name}")
count = count + 1 count = count + 1
@ -1333,6 +1336,9 @@ module ApplicationHelper
def show_fans_picture(obj) def show_fans_picture(obj)
html = '' html = ''
count = 0 count = 0
if obj.watcher_users.count == 0
html << (content_tag "span", l(:label_no_current_fans))
end
for user in obj.watcher_users for user in obj.watcher_users
html << (link_to image_tag(url_to_avatar(user), :class => "avatar"), user_path(user), :class => "avatar", :title => "#{user.name}") html << (link_to image_tag(url_to_avatar(user), :class => "avatar"), user_path(user), :class => "avatar", :title => "#{user.name}")
count = count + 1 count = count + 1

View File

@ -99,7 +99,9 @@ class User < Principal
acts_as_taggable acts_as_taggable
scope :by_join_date, order("created_at DESC") scope :by_join_date, order("created_at DESC")
############################# added by liuping 关注 ############################# added by liuping 关注
acts_as_watchable acts_as_watchable
has_one :user_extensions
## end
attr_accessor :password, :password_confirmation attr_accessor :password, :password_confirmation
attr_accessor :last_before_login_on attr_accessor :last_before_login_on

View File

@ -1,4 +1,5 @@
class UserExtensions < ActiveRecord::Base class UserExtensions < ActiveRecord::Base
belongs_to :user
attr_accessible :user_id,:birthday,:brief_introduction,:gender,:location,:occupation,:work_experience,:zip_code attr_accessible :user_id,:birthday,:brief_introduction,:gender,:location,:occupation,:work_experience,:zip_code
#this method was used to update the table user_extensions #this method was used to update the table user_extensions
def update_user_extensions(birthday=nil,brief_introduction=nil, def update_user_extensions(birthday=nil,brief_introduction=nil,

View File

@ -5,8 +5,6 @@
<h3 style="padding-left: 10px;"><%= l(:label_my_account)%></h3> <h3 style="padding-left: 10px;"><%= l(:label_my_account)%></h3>
<fieldset class="box" style="margin:10px;"> <fieldset class="box" style="margin:10px;">
<fieldset class="collapsible collapsed" style="width:800px;margin-left: 10px;"> <fieldset class="collapsible collapsed" style="width:800px;margin-left: 10px;">
<legend onclick="toggleFieldset(this);"> <legend onclick="toggleFieldset(this);">
@ -70,6 +68,15 @@
<div> <div>
<%= render :partial => 'users/preferences' %></div> <%= render :partial => 'users/preferences' %></div>
</fieldset> </fieldset>
<!-- added by william -->
<fieldset class="collapsible collapsed" style="width:800px;margin-left: 10px;">
<legend onclick="toggleFieldset(this);">
<%= l(:label_user_extensions)%>
</legend>
<div>
<%= render :partial => 'users/user_extensions' %></div>
</fieldset>
<!-- end -->
<%= submit_tag l(:button_save) %> <%= submit_tag l(:button_save) %>
</fieldset> </fieldset>
<% end %> <% end %>

View File

@ -25,7 +25,7 @@
<!-- <p class="pagination"><%= pagination_links_full @project_pages%></p> --> <!-- <p class="pagination"><%= pagination_links_full @project_pages%></p> -->
<div class="pagination"> <div class="pagination">
<ul> <ul>
<%= pagination_links_full @project_pages%> <%= pagination_links_full @project_pages %>
</ul> </ul>
</div> </div>

View File

@ -1,5 +1,5 @@
<% if related_tags %> <% if related_tags %>
<ul> <ul style="list-style-type: none">
<% for rt in related_tags %> <% for rt in related_tags %>
<li> <li>
<%= link_to image_tag("/images/sidebar/add.png"),:action => "add_tag",:remote => true,:tag => rt,:show_flag => show_flag %> <%= link_to image_tag("/images/sidebar/add.png"),:action => "add_tag",:remote => true,:tag => rt,:show_flag => show_flag %>

View File

@ -1,5 +1,5 @@
<% if selected_tags %> <% if selected_tags %>
<ul> <ul style="list-style-type: none">
<% for sg in selected_tags %> <% for sg in selected_tags %>
<li> <li>
<%= link_to image_tag("/images/sidebar/minus.png"),:action => "delete_tag",:remote=>true,:tag => sg,:show_flag => show_flag %> <%= link_to image_tag("/images/sidebar/minus.png"),:action => "delete_tag",:remote=>true,:tag => sg,:show_flag => show_flag %>

View File

@ -11,3 +11,8 @@
<% end %> <% end %>
<% end %> <% end %>
</div> </div>
<div class="pagination" style="float:right;">
<ul>
<%= pagination_links_full @obj_pages %>
<ul>
</div>

View File

@ -12,3 +12,8 @@
<% end %> <% end %>
</div> </div>
<div class="pagination" style="float:right;">
<ul>
<%= pagination_links_full @obj_pages %>
<ul>
</div>

View File

@ -11,6 +11,10 @@
</div> </div>
<div class="line_under"></div> <div class="line_under"></div>
<% end %> <% end %>
<% end %> <% end %>
</div> </div>
<div class="pagination" style="float:right;">
<ul>
<%= pagination_links_full @obj_pages %>
<ul>
</div>

View File

@ -12,3 +12,8 @@
<% end %> <% end %>
<% end %> <% end %>
</div> </div>
<div class="pagination" style="float:right;">
<ul>
<%= pagination_links_full @obj_pages %>
<ul>
</div>

View File

@ -41,7 +41,7 @@
<%= form_for "tag_for_save",:remote=>true,:url=>tag_path, <%= form_for "tag_for_save",:remote=>true,:url=>tag_path,
:update => "tags_show", :update => "tags_show",
:complete => '$("#put-tag-form").hide();' do |f| %> :complete => '$("#put-tag-form").hide();' do |f| %>
<%= f.text_field :name ,:id => "name",:size=>"28",:require=>true,:maxlength => 25,:minlength=>1 %> <%= f.text_field :name ,:id => "name",:size=>"28",:require=>true,:maxlength => Setting.tags_max_length,:minlength=>Setting.tags_min_length %>
<%= f.text_field :object_id,:value=> obj.id,:style=>"display:none"%> <%= f.text_field :object_id,:value=> obj.id,:style=>"display:none"%>
<%= f.text_field :object_flag,:value=> object_flag,:style=>"display:none"%> <%= f.text_field :object_flag,:value=> object_flag,:style=>"display:none"%>
<%= f.submit "add"%> <%= f.submit "add"%>

View File

@ -3,7 +3,7 @@
<% case %> <% case %>
<% when show_flag == '1' %> <% when show_flag == '1' %>
<strong><%=l(:label_user)%><strong> <strong><%=l(:label_user)%><strong>
<%= render :partial => "show_users",:locals => {:users_results => users_results }%> <%= render :partial => "show_users",:locals => {:users_results => users_results}%>
<% when show_flag == '2'%> <% when show_flag == '2'%>
<strong><%=l(:label_project)%></strong> <strong><%=l(:label_project)%></strong>
<%= render :partial => "show_projects",:locals => {:projects_results => projects_results }%> <%= render :partial => "show_projects",:locals => {:projects_results => projects_results }%>
@ -12,7 +12,7 @@
<%= render :partial => "show_issues",:locals => {:issues_results => issues_results }%> <%= render :partial => "show_issues",:locals => {:issues_results => issues_results }%>
<% when show_flag == '4'%> <% when show_flag == '4'%>
<strong><%= l(:label_requirement)%></strong> <strong><%= l(:label_requirement)%></strong>
<%= render :partial => "show_bids",:locals => {:bids_results => bids_results }%> <%= render :partial => "show_bids",:locals => {:bids_results => bids_results}%>
<% else %> <% else %>
<strong><%= l(:label_tags_all_objects)%></strong> <strong><%= l(:label_tags_all_objects)%></strong>
<%= render :partial => "show_issues",:locals => {:issues_results => issues_results }%> <%= render :partial => "show_issues",:locals => {:issues_results => issues_results }%>

View File

@ -1,10 +1,11 @@
<% content_for :sidebar do %> <% content_for :sidebar do %>
<div> <div>
<strong>Selected Tags</strong> <h3><strong>Selected Tags</strong></h3>
<div id="selected_tags"> <div id="selected_tags">
<%= render :partial => "selected_tags",:locals => {:selected_tags => $selected_tags,:show_flag => @obj_flag}%> <%= render :partial => "selected_tags",:locals => {:selected_tags => $selected_tags,:show_flag => @obj_flag}%>
</div> </div>
<strong>Related Tags</strong>
<h3><strong>Related Tags</strong></h3>
<div id="related_tags"> <div id="related_tags">
<%= render :partial => "related_tags",:locals => {:related_tags => $related_tags,:show_flag => @obj_flag }%> <%= render :partial => "related_tags",:locals => {:related_tags => $related_tags,:show_flag => @obj_flag }%>
</div> </div>
@ -13,7 +14,7 @@
<% content_for :content do %> <% content_for :content do %>
<div> <div>
<h3><strong>Search Results</strong></h3> <h3><strong>Search Results</strong></h3>
<div id="filter-menu" align="right"> <div align="right">
<%= l(:label_tags_numbers) %> <%= l(:label_tags_numbers) %>
<%= l(:label_issue_plural) %>(<%= @issues_tags_num %>)| <%= l(:label_issue_plural) %>(<%= @issues_tags_num %>)|
<%= l(:label_project_plural) %>(<%= @projects_tags_num %>)| <%= l(:label_project_plural) %>(<%= @projects_tags_num %>)|

View File

@ -0,0 +1,26 @@
<%= labelled_fields_for :user_extensions, @user.user_extensions do |user_extension| %>
<p style="width:400px;padding-left: 26px;">
<%= user_extension.text_field :birthday %>
</p>
<p style="width:400px;">
<%= user_extension.select :gender, [[l(:label_boy), '1'], [l(:label_girl), '0']] %>
</p>
<p style="width:400px;padding-left: 26px;">
<%= user_extension.text_area :brief_introduction %>(少于250字)
</p>
<p style="width:400px;padding-left: 26px;">
<%= user_extension.text_field :location %>
</p>
<p style="width:400px;padding-left: 26px;">
<%= user_extension.text_field :occupation %>
</p>
<p style="width:400px;padding-left: 26px;">
<%= user_extension.text_field :work_experience %>
</p>
<p style="width:400px;padding-left: 26px;">
<%= user_extension.text_field :zip_code %>
</p>
<% end %>

View File

@ -1173,6 +1173,18 @@ zh:
label_tags_bid_description: 需求描述 label_tags_bid_description: 需求描述
label_tags_issue_description: 问题描述 label_tags_issue_description: 问题描述
label_tags_all_objects: 所有 label_tags_all_objects: 所有
label_user_extensions: 其他信息
label_boy:
label_girl:
field_gender: 性别
field_birthday: 生日
field_brief_introduction: 个人简介
field_location: 现住址
field_occupation: 学校/公司
field_work_experience: 工作经验(年)
field_zip_code: 邮编
#fq #fq
button_leave_meassge: 留言 button_leave_meassge: 留言
label_leave_message_to: 给用户 %{name}留言 label_leave_message_to: 给用户 %{name}留言
@ -1261,9 +1273,11 @@ zh:
label_tags_user_mail: 用户邮箱: label_tags_user_mail: 用户邮箱:
label_tags_numbers: Tag统计 label_tags_numbers: Tag统计
label_max_number: 至多25个字符。 label_max_number: 至多25个字符。
label_mail_attention: qq邮箱可能收不到此邮件其他邮箱如果没有收到可能在垃圾邮件中
label_all_revisions: 所有版本: label_all_revisions: 所有版本:
label_upassword_info: 该密码在项目组内可共享 label_upassword_info: 该密码在项目组内可共享
label_how_commit_code: 如何提交代码: label_how_commit_code: 如何提交代码:
label_how_commit_code_chinese: 中文 label_how_commit_code_chinese: 中文
label_welcome_leave_message: 朋友,系统仍在不断完善,有意见和建议请 label_welcome_leave_message: 朋友,系统仍在不断完善,有意见和建议请
label_welcome_click_me: 点击我 label_welcome_click_me: 点击我
label_mail_attention: qq邮箱可能收不到此邮件其他邮箱如果没有收到可能在垃圾邮件中

View File

@ -234,12 +234,12 @@ non_working_week_days:
show_tags_length: show_tags_length:
format: int format: int
default: 5 default: 5
show_tags_length:
format: int
default: 5
tags_min_length: tags_min_length:
format: int format: int
default: 1 default: 1
tags_max_length: tags_max_length:
format: int format: int
default: 25 default: 13
tags_show_search_results:
format: int
default: 5

View File

@ -0,0 +1,119 @@
require_relative 'shell_env'
require_relative 'grack_ldap'
require_relative 'grack_helpers'
module Grack
class Auth < Rack::Auth::Basic
include LDAP
include Helpers
attr_accessor :user, :project, :ref, :env
def call(env)
@env = env
@request = Rack::Request.new(env)
@auth = Request.new(env)
# Need this patch due to the rails mount
@env['PATH_INFO'] = @request.path
@env['SCRIPT_NAME'] = ""
auth!
end
private
def auth!
return render_not_found unless project
if @auth.provided?
return bad_request unless @auth.basic?
# Authentication with username and password
login, password = @auth.credentials
@user = authenticate_user(login, password)
if @user
Gitlab::ShellEnv.set_env(@user)
@env['REMOTE_USER'] = @auth.username
else
return unauthorized
end
else
return unauthorized unless project.public
end
if authorized_git_request?
@app.call(env)
else
unauthorized
end
end
def authorized_git_request?
# Git upload and receive
if @request.get?
authorize_request(@request.params['service'])
elsif @request.post?
authorize_request(File.basename(@request.path))
else
false
end
end
def authenticate_user(login, password)
user = User.find_by_email(login) || User.find_by_username(login)
# If the provided login was not a known email or username
# then user is nil
if user.nil? || user.ldap_user?
# Second chance - try LDAP authentication
return nil unless ldap_conf.enabled
auth = Gitlab::Auth.new
auth.ldap_auth(login, password)
else
return user if user.valid_password?(password)
end
end
def authorize_request(service)
case service
when 'git-upload-pack'
project.public || can?(user, :download_code, project)
when'git-receive-pack'
action = if project.protected_branch?(ref)
:push_code_to_protected_branches
else
:push_code
end
can?(user, action, project)
else
false
end
end
def project
@project ||= project_by_path(@request.path_info)
end
def ref
@ref ||= parse_ref
end
def parse_ref
input = if @env["HTTP_CONTENT_ENCODING"] =~ /gzip/
Zlib::GzipReader.new(@request.body).read
else
@request.body.read
end
# Need to reset seek point
@request.body.rewind
/refs\/heads\/([\w\.-]+)/n.match(input.force_encoding('ascii-8bit')).to_a.last
end
end
end

View File

@ -0,0 +1,28 @@
module Grack
module Helpers
def project_by_path(path)
if m = /^\/([\w\.\/-]+)\.git/.match(path).to_a
path_with_namespace = m.last
path_with_namespace.gsub!(/\.wiki$/, '')
Project.find_with_namespace(path_with_namespace)
end
end
def render_not_found
[404, {"Content-Type" => "text/plain"}, ["Not Found"]]
end
def can?(object, action, subject)
abilities.allowed?(object, action, subject)
end
def abilities
@abilities ||= begin
abilities = Six.new
abilities << Ability
abilities
end
end
end
end

View File

@ -0,0 +1,24 @@
require 'omniauth-ldap'
module Grack
module LDAP
def ldap_auth(login, password)
# Check user against LDAP backend if user is not authenticated
# Only check with valid login and password to prevent anonymous bind results
return nil unless ldap_conf.enabled && !login.blank? && !password.blank?
ldap = OmniAuth::LDAP::Adaptor.new(ldap_conf)
ldap_user = ldap.bind_as(
filter: Net::LDAP::Filter.eq(ldap.uid, login),
size: 1,
password: password
)
User.find_by_extern_uid_and_provider(ldap_user.dn, 'ldap') if ldap_user
end
def ldap_conf
@ldap_conf ||= Gitlab.config.ldap
end
end
end

148
lib/git/backend/shell.rb Normal file
View File

@ -0,0 +1,148 @@
module Gitlab
class Shell
class AccessDenied < StandardError; end
# Init new repository
#
# name - project path with namespace
#
# Ex.
# add_repository("gitlab/gitlab-ci")
#
def add_repository(name)
system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "add-project", "#{name}.git"
end
# Import repository
#
# name - project path with namespace
#
# Ex.
# import_repository("gitlab/gitlab-ci", "https://github.com/randx/six.git")
#
def import_repository(name, url)
system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "import-project", "#{name}.git", url
end
# Move repository
#
# path - project path with namespace
# new_path - new project path with namespace
#
# Ex.
# mv_repository("gitlab/gitlab-ci", "randx/gitlab-ci-new.git")
#
def mv_repository(path, new_path)
system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "mv-project", "#{path}.git", "#{new_path}.git"
end
# Fork repository to new namespace
#
# path - project path with namespace
# fork_namespace - namespace for forked project
#
# Ex.
# fork_repository("gitlab/gitlab-ci", "randx")
#
def fork_repository(path, fork_namespace)
system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "fork-project", "#{path}.git", fork_namespace
end
# Remove repository from file system
#
# name - project path with namespace
#
# Ex.
# remove_repository("gitlab/gitlab-ci")
#
def remove_repository(name)
system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "rm-project", "#{name}.git"
end
# Add new key to gitlab-shell
#
# Ex.
# add_key("key-42", "sha-rsa ...")
#
def add_key(key_id, key_content)
system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-keys", "add-key", key_id, key_content
end
# Remove ssh key from gitlab shell
#
# Ex.
# remove_key("key-342", "sha-rsa ...")
#
def remove_key(key_id, key_content)
system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-keys", "rm-key", key_id, key_content
end
# Add empty directory for storing repositories
#
# Ex.
# add_namespace("gitlab")
#
def add_namespace(name)
FileUtils.mkdir(full_path(name), mode: 0770) unless exists?(name)
end
# Remove directory from repositories storage
# Every repository inside this directory will be removed too
#
# Ex.
# rm_namespace("gitlab")
#
def rm_namespace(name)
FileUtils.rm_r(full_path(name), force: true)
end
# Move namespace directory inside repositories storage
#
# Ex.
# mv_namespace("gitlab", "gitlabhq")
#
def mv_namespace(old_name, new_name)
return false if exists?(new_name) || !exists?(old_name)
FileUtils.mv(full_path(old_name), full_path(new_name))
end
# Remove GitLab Satellites for provided path (namespace or repo dir)
#
# Ex.
# rm_satellites("gitlab")
#
# rm_satellites("gitlab/gitlab-ci.git")
#
def rm_satellites(path)
raise ArgumentError.new("Path can't be blank") if path.blank?
satellites_path = File.join(Gitlab.config.satellites.path, path)
FileUtils.rm_r(satellites_path, force: true)
end
def url_to_repo path
Gitlab.config.gitlab_shell.ssh_path_prefix + "#{path}.git"
end
protected
def gitlab_shell_user_home
File.expand_path("~#{Gitlab.config.gitlab_shell.ssh_user}")
end
def repos_path
Gitlab.config.gitlab_shell.repos_path
end
def full_path(dir_name)
raise ArgumentError.new("Directory name can't be blank") if dir_name.blank?
File.join(repos_path, dir_name)
end
def exists?(dir_name)
File.exists?(full_path(dir_name))
end
end
end

View File

@ -0,0 +1,12 @@
# == GitLab Shell mixin
#
# Provide a shortcut to Gitlab::Shell instance by gitlab_shell
#
module Gitlab
module ShellAdapter
def gitlab_shell
Gitlab::Shell.new
end
end
end

View File

@ -0,0 +1,17 @@
module Gitlab
# This module provide 2 methods
# to set specific ENV variabled for GitLab Shell
module ShellEnv
extend self
def set_env(user)
# Set GL_ID env variable
ENV['GL_ID'] = "user-#{user.id}"
end
def reset_env
# Reset GL_ID env variable
ENV['GL_ID'] = nil
end
end
end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

@ -251,6 +251,7 @@ a
font-size: 11px; font-size: 11px;
border-radius:3px; border-radius:3px;
-moz-border-radius:3px; -moz-border-radius:3px;
-webkit-border-radius:3px; -webkit-border-radius:3px;
-o-border-radius:3px; -o-border-radius:3px;
-ms-border-radius:3px; -ms-border-radius:3px;
@ -1070,7 +1071,9 @@ pre,code,.line-code
} }
div.project_tag_info a.root {
font-size: 1.5em;
}
div.wiki-description { div.wiki-description {
/*word-break; break-all; /*word-break; break-all;