diff options
Diffstat (limited to 'app/controllers/projects')
-rw-r--r-- | app/controllers/projects/blob_controller.rb | 8 | ||||
-rw-r--r-- | app/controllers/projects/tree_controller.rb | 17 |
2 files changed, 17 insertions, 8 deletions
diff --git a/app/controllers/projects/blob_controller.rb b/app/controllers/projects/blob_controller.rb index 49ea2945675..721e174d587 100644 --- a/app/controllers/projects/blob_controller.rb +++ b/app/controllers/projects/blob_controller.rb @@ -4,6 +4,7 @@ class Projects::BlobController < Projects::ApplicationController include CreatesCommit include RendersBlob include ActionView::Helpers::SanitizeHelper + include ApplicationHelper # Raised when given an invalid file path InvalidPathError = Class.new(StandardError) @@ -37,12 +38,13 @@ class Projects::BlobController < Projects::ApplicationController respond_to do |format| format.html do + assign_ref_vars + environment_params = @repository.branch_exists?(@ref) ? { ref: @ref } : { commit: @commit } @environment = EnvironmentsFinder.new(@project, current_user, environment_params).execute.last + @last_commit = @repository.last_commit_for_path(@commit.id, tree.path) || @commit - @last_commit = @repository.last_commit_for_path(@commit.id, @blob.path) - - render 'show' + show_new_repo? ? render('projects/tree/show') : render('show') end format.json do diff --git a/app/controllers/projects/tree_controller.rb b/app/controllers/projects/tree_controller.rb index 30181ac3bdf..1fc276b8c03 100644 --- a/app/controllers/projects/tree_controller.rb +++ b/app/controllers/projects/tree_controller.rb @@ -24,12 +24,19 @@ class Projects::TreeController < Projects::ApplicationController end end - @last_commit = @repository.last_commit_for_path(@commit.id, @tree.path) || @commit - respond_to do |format| - format.html - # Disable cache so browser history works - format.js { no_cache_headers } + format.html do + @last_commit = @repository.last_commit_for_path(@commit.id, @tree.path) || @commit + end + + format.js do + # Disable cache so browser history works + no_cache_headers + end + + format.json do + render json: TreeSerializer.new(project: @project, repository: @repository, ref: @ref).represent(@tree) + end end end |