diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 2d1f8d771..bd3998621 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -405,11 +405,16 @@ class ProjectsController < ApplicationController
end
flash.now[:error] = html if !html.to_s.blank?
end
- scm = params[:repository_scm] || (Redmine::Scm::Base.all & Setting.enabled_scm).first
- @repository = Repository.factory(scm)
- @repository.is_default = @project.repository.nil?
- @repository.project = @project
-
+ scm = params[:repository_scm] || (Redmine::Scm::Base.all & Setting.enabled_scm).first
+ @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
diff --git a/app/views/projects/settings/_new_edit.html.erb b/app/views/projects/settings/_new_edit.html.erb
index 1d204a52b..eef87bc9b 100644
--- a/app/views/projects/settings/_new_edit.html.erb
+++ b/app/views/projects/settings/_new_edit.html.erb
@@ -18,6 +18,13 @@
+ <% if !@project.gpid.nil? && !@gitlab_branches.blank? %>
+
+
+ <%= select_tag :branch, options_for_select(["#{@gitlab_default_branch}"]+ @branch_names, @rev), :id => 'branch' %>
+
+ <% end %>
+
>
diff --git a/app/views/projects/settings/_new_repositories.html.erb b/app/views/projects/settings/_new_repositories.html.erb
index 43535153d..07b2896eb 100644
--- a/app/views/projects/settings/_new_repositories.html.erb
+++ b/app/views/projects/settings/_new_repositories.html.erb
@@ -46,9 +46,9 @@
*<%=l(:label_repository_name)%>:
<%= f.text_field :identifier, :disabled =>@repository.nil? || @repository.identifier_frozen? ? true:false,:label=>"", :no_label => true %>
- <% unless @repository.identifier_frozen? %>
+ <%# unless @repository.identifier_frozen? %>
<%=l(:text_length_between,:min=>1,:max=>254)<
- <% end %>
+ <%# end %>
diff --git a/app/views/repositories/_navigation.html.erb b/app/views/repositories/_navigation.html.erb
index c3e154f17..d99df5ed1 100644
--- a/app/views/repositories/_navigation.html.erb
+++ b/app/views/repositories/_navigation.html.erb
@@ -18,7 +18,7 @@
<% 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 -%>
diff --git a/lib/gitlab-cli/lib/gitlab/client/projects.rb b/lib/gitlab-cli/lib/gitlab/client/projects.rb
index 8d91edd06..2cc96c4d1 100644
--- a/lib/gitlab-cli/lib/gitlab/client/projects.rb
+++ b/lib/gitlab-cli/lib/gitlab/client/projects.rb
@@ -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.