Merge branch 'develop' of https://git.trustie.net/jacknudt/trustieforge into develop

This commit is contained in:
cxt 2016-02-29 08:53:31 +08:00
commit 6ba91cb3fe
5 changed files with 23 additions and 12 deletions

View File

@ -409,7 +409,12 @@ class ProjectsController < ApplicationController
@repository = Repository.factory(scm)
@repository.is_default = @project.repository.nil?
@repository.project = @project
unless @project.gpid.nil?
g = Gitlab.client
@gitlab_branches = g.branches(@project.gpid)
@branch_names = g.branches(@project.gpid).map{|b| b.name}
@gitlab_default_branch = g.project(@project.gpid).default_branch
end
end
# 项目邀请用户加入实现过程
@ -670,8 +675,7 @@ class ProjectsController < ApplicationController
# 更新公开私有时同步gitlab公开私有
unless @project.gpid.nil?
g = Gitlab.client
gproject = g.project(@project.gpid)
params[:project][:is_public] ? g.edit_project(gproject.id, 20) : g.edit_project(gproject.id, 0)
params[:project][:is_public] ? g.edit_project(@project.gpid, 20, params[:branch]) : g.edit_project(@project.gpid, 0, params[:branch])
end
# end
if validate_parent_id && @project.save

View File

@ -18,6 +18,13 @@
<textarea class="w543" id="project_description" name="project[description]" rows="8" placeholder="最多3000个汉字(或6000个英文字符)"><%= @project.description%></textarea>
<div class="cl"></div>
</li>
<% if !@project.gpid.nil? && !@gitlab_branches.blank? %>
<li>
<label class="label02">&nbsp;默认分支&nbsp;&nbsp;</label>
<%= select_tag :branch, options_for_select(["#{@gitlab_default_branch}"]+ @branch_names, @rev), :id => 'branch' %>
</li>
<% end %>
<div class="cl"></div>
<li >
<label class="label02">公开&nbsp;&nbsp;</label>
<input id="project_is_public" name="project[is_public]" type="checkbox" <%= @project.is_public ? "checked" : ""%>>

View File

@ -46,9 +46,9 @@
<input type="password" style="display: none"/> <!--阻止表单自动填充 -->
<span class="f14"><span class="c_red">*</span><%=l(:label_repository_name)%></span>
<%= f.text_field :identifier, :disabled =>@repository.nil? || @repository.identifier_frozen? ? true:false,:label=>"", :no_label => true %>
<% unless @repository.identifier_frozen? %>
<%# unless @repository.identifier_frozen? %>
<span class="c_grey"><%=l(:text_length_between,:min=>1,:max=>254)<<l(:text_project_identifier_info) %></span>
<% end %>
<%# end %>
</li>
<div class="cl"></div>
</ul>

View File

@ -18,7 +18,7 @@
<!-- Branches Dropdown -->
<% if !@repository.branches.nil? && @repository.branches.length > 0 -%>
<%= l(:label_branch) %>:
<%= select_tag :branch, options_for_select([''] + @repository.branches, @rev), :id => 'branch' %>
<%= select_tag :branch, options_for_select(@repository.branches, @rev), :id => 'branch' %>
<% end -%>
<% if !@repository.tags.nil? && @repository.tags.length > 0 -%>

View File

@ -85,8 +85,8 @@ class Gitlab::Client
# public (optional) - if true same as setting visibility_level = 20
# visibility_level (optional)
def edit_project(id, visibility_level)
put("/projects/#{id}", :body => {:visibility_level => visibility_level})
def edit_project(id, visibility_level, default_branch)
put("/projects/#{id}", :body => {:visibility_level => visibility_level, :default_branch => default_branch})
end
# Deletes a project.