Commit 970d86b7c5d0be871d8ab8d7cbd51997fd62e28a
1 parent
68d89548
Exists in
master
and in
4 other branches
Refactor blob finding
Showing
7 changed files
with
12 additions
and
13 deletions
Show diff stats
app/controllers/projects/blame_controller.rb
@@ -8,7 +8,7 @@ class Projects::BlameController < Projects::ApplicationController | @@ -8,7 +8,7 @@ class Projects::BlameController < Projects::ApplicationController | ||
8 | before_filter :require_non_empty_project | 8 | before_filter :require_non_empty_project |
9 | 9 | ||
10 | def show | 10 | def show |
11 | - @blob = Gitlab::Git::Blob.find(@repository, @commit.id, @path) | 11 | + @blob = @repository.blob_at(@commit.id, @path) |
12 | @blame = Gitlab::Git::Blame.new(project.repository, @commit.id, @path) | 12 | @blame = Gitlab::Git::Blame.new(project.repository, @commit.id, @path) |
13 | end | 13 | end |
14 | end | 14 | end |
app/controllers/projects/blob_controller.rb
@@ -8,7 +8,7 @@ class Projects::BlobController < Projects::ApplicationController | @@ -8,7 +8,7 @@ class Projects::BlobController < Projects::ApplicationController | ||
8 | before_filter :require_non_empty_project | 8 | before_filter :require_non_empty_project |
9 | 9 | ||
10 | def show | 10 | def show |
11 | - @blob = Gitlab::Git::Blob.find(@repository, @commit.id, @path) | 11 | + @blob = @repository.blob_at(@commit.id, @path) |
12 | 12 | ||
13 | not_found! unless @blob | 13 | not_found! unless @blob |
14 | end | 14 | end |
app/controllers/projects/edit_tree_controller.rb
@@ -10,7 +10,7 @@ class Projects::EditTreeController < Projects::ApplicationController | @@ -10,7 +10,7 @@ class Projects::EditTreeController < Projects::ApplicationController | ||
10 | before_filter :edit_requirements, only: [:show, :update] | 10 | before_filter :edit_requirements, only: [:show, :update] |
11 | 11 | ||
12 | def show | 12 | def show |
13 | - @last_commit = Gitlab::Git::Commit.last_for_path(@project.repository, @ref, @path).sha | 13 | + @last_commit = Gitlab::Git::Commit.last_for_path(@repository, @ref, @path).sha |
14 | end | 14 | end |
15 | 15 | ||
16 | def update | 16 | def update |
@@ -32,7 +32,7 @@ class Projects::EditTreeController < Projects::ApplicationController | @@ -32,7 +32,7 @@ class Projects::EditTreeController < Projects::ApplicationController | ||
32 | private | 32 | private |
33 | 33 | ||
34 | def edit_requirements | 34 | def edit_requirements |
35 | - @blob = Gitlab::Git::Blob.find(@repository, @commit.id, @path) | 35 | + @blob = @repository.blob_at(@commit.id, @path) |
36 | 36 | ||
37 | unless @blob | 37 | unless @blob |
38 | redirect_to project_blob_path(@project, @id), notice: "You can only edit text files" | 38 | redirect_to project_blob_path(@project, @id), notice: "You can only edit text files" |
app/controllers/projects/raw_controller.rb
@@ -8,7 +8,7 @@ class Projects::RawController < Projects::ApplicationController | @@ -8,7 +8,7 @@ class Projects::RawController < Projects::ApplicationController | ||
8 | before_filter :require_non_empty_project | 8 | before_filter :require_non_empty_project |
9 | 9 | ||
10 | def show | 10 | def show |
11 | - @blob = Gitlab::Git::Blob.find(@repository, @commit.id, @path) | 11 | + @blob = @repository.blob_at(@commit.id, @path) |
12 | 12 | ||
13 | if @blob | 13 | if @blob |
14 | type = if @blob.mime_type =~ /html|javascript/ | 14 | type = if @blob.mime_type =~ /html|javascript/ |
app/helpers/blobs_helper.rb
app/models/repository.rb
app/views/projects/commits/_diffs.html.haml
@@ -37,8 +37,8 @@ | @@ -37,8 +37,8 @@ | ||
37 | - unless @suppress_diff | 37 | - unless @suppress_diff |
38 | - diffs.each_with_index do |diff, i| | 38 | - diffs.each_with_index do |diff, i| |
39 | - next if diff.diff.empty? | 39 | - next if diff.diff.empty? |
40 | - - file = find_blob(project.repository, @commit.id, diff.new_path) | ||
41 | - - file = find_blob(project.repository, @commit.parent_id, diff.old_path) unless file | 40 | + - file = project.repository.blob_at(@commit.id, diff.new_path) |
41 | + - file = project.repository.blob_at(@commit.parent_id, diff.old_path) unless file | ||
42 | - next unless file | 42 | - next unless file |
43 | .file{id: "diff-#{i}"} | 43 | .file{id: "diff-#{i}"} |
44 | .header | 44 | .header |
@@ -64,7 +64,7 @@ | @@ -64,7 +64,7 @@ | ||
64 | - if file.text? | 64 | - if file.text? |
65 | = render "projects/commits/text_file", diff: diff, index: i | 65 | = render "projects/commits/text_file", diff: diff, index: i |
66 | - elsif file.image? | 66 | - elsif file.image? |
67 | - - old_file = find_blob(project.repository, @commit.parent_id, diff.old_path) if @commit.parent_id | 67 | + - old_file = project.repository.blob_at(@commit.parent_id, diff.old_path) if @commit.parent_id |
68 | = render "projects/commits/image", diff: diff, old_file: old_file, file: file, index: i | 68 | = render "projects/commits/image", diff: diff, old_file: old_file, file: file, index: i |
69 | - else | 69 | - else |
70 | %p.nothing_here_message No preview for this file type | 70 | %p.nothing_here_message No preview for this file type |