Merge pull request #948 from warpc/944-fix_branch_errors
[refs #944] Fix branch errors: - empty project; - show branches pages when active tag selection.
This commit is contained in:
commit
7a8dcc1b10
|
@ -10,7 +10,7 @@ class Projects::Git::BaseController < Projects::BaseController
|
|||
protected
|
||||
|
||||
def set_treeish_and_path
|
||||
@treeish, @path = @project.default_head(params[:treeish]), params[:path]
|
||||
@treeish, @path = params[:treeish].presence || @project.default_head, params[:path]
|
||||
end
|
||||
|
||||
def set_branch_and_tree
|
||||
|
|
|
@ -4,9 +4,10 @@ class Projects::Git::TreesController < Projects::Git::BaseController
|
|||
skip_before_filter :set_branch_and_tree, :set_treeish_and_path, :only => :archive
|
||||
|
||||
def show
|
||||
render('empty') and return unless @project.repo.commit nil
|
||||
@tree = @tree / @path if @path.present?
|
||||
@commit = @branch.present? ? @branch.commit() : @project.repo.log(@treeish, @path, :max_count => 1).first
|
||||
render 'empty' unless @commit
|
||||
raise Grit::NoSuchPathError unless @commit
|
||||
end
|
||||
|
||||
def archive
|
||||
|
@ -32,7 +33,8 @@ class Projects::Git::TreesController < Projects::Git::BaseController
|
|||
end
|
||||
|
||||
def branches
|
||||
@branches = @project.repo.branches.sort_by(&:name).select{ |b| b.name != @branch.name }.unshift(@branch)
|
||||
raise Grit::NoSuchPathError if !@branch && @project.repo.commit(nil)
|
||||
@branches = @project.repo.branches.sort_by(&:name).select{ |b| b.name != @branch.name }.unshift(@branch).compact
|
||||
render 'refs'
|
||||
end
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
- act = action_name.to_sym; contr = controller_name.to_sym; treeish = project.default_head(params[:treeish])
|
||||
- act = action_name.to_sym; contr = controller_name.to_sym; treeish = project.default_head(params[:treeish]); branch = @branch.try(:name) || project.default_head
|
||||
#description-top
|
||||
-if @commit
|
||||
%ul.nav.zip
|
||||
|
@ -34,7 +34,7 @@
|
|||
%li{:class => ('selected' if act == :index && contr == :commits )}
|
||||
= link_to t('project_menu.commits'), commits_path(project, treeish)
|
||||
%li{:class => ('selected' if act == :branches && contr == :trees )}
|
||||
= link_to t('project_menu.branches', :count => project.repo.branches.count), branches_path(project, treeish)
|
||||
= link_to t('project_menu.branches', :count => project.repo.branches.count), branches_path(project, branch)
|
||||
%li.tags{:class => ('selected' if act == :tags && contr == :trees )}
|
||||
= link_to t('project_menu.tags', :count => project.repo.tags.count), tags_path(project)
|
||||
.both
|
||||
|
|
Loading…
Reference in New Issue