diff --git a/app/controllers/projects/git/trees_controller.rb b/app/controllers/projects/git/trees_controller.rb index 68c264681..a9e7ba396 100644 --- a/app/controllers/projects/git/trees_controller.rb +++ b/app/controllers/projects/git/trees_controller.rb @@ -4,7 +4,7 @@ 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 if @project.repo.branches.count == 0 + render('empty') and return if @project.empty? @tree = @tree / @path if @path.present? @commit = @branch.present? ? @branch.commit() : @project.repo.log(@treeish, @path, :max_count => 1).first raise Grit::NoSuchPathError unless @commit @@ -33,7 +33,7 @@ class Projects::Git::TreesController < Projects::Git::BaseController end def branches - raise Grit::NoSuchPathError if !@branch && @project.repo.branches.count != 0 + raise Grit::NoSuchPathError if !(@branch && @project.empty?) @branches = @project.repo.branches.sort_by(&:name).select{ |b| b.name != @branch.name }.unshift(@branch).compact render 'refs' end diff --git a/lib/modules/models/git.rb b/lib/modules/models/git.rb index a8269209a..04b7dc6d6 100644 --- a/lib/modules/models/git.rb +++ b/lib/modules/models/git.rb @@ -97,6 +97,10 @@ module Modules system("#{Rails.root.join('bin', 'import_srpm.sh')} #{opts} >> /dev/null 2>&1") end + def empty? + repo.branches.count == 0 + end + protected def build_path(dir)