Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
970d86b7
Commit
970d86b7
authored
Oct 01, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor blob finding
parent
68d89548
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
12 additions
and
13 deletions
+12
-13
app/controllers/projects/blame_controller.rb
app/controllers/projects/blame_controller.rb
+1
-1
app/controllers/projects/blob_controller.rb
app/controllers/projects/blob_controller.rb
+1
-1
app/controllers/projects/edit_tree_controller.rb
app/controllers/projects/edit_tree_controller.rb
+2
-2
app/controllers/projects/raw_controller.rb
app/controllers/projects/raw_controller.rb
+1
-1
app/helpers/blobs_helper.rb
app/helpers/blobs_helper.rb
+0
-5
app/models/repository.rb
app/models/repository.rb
+4
-0
app/views/projects/commits/_diffs.html.haml
app/views/projects/commits/_diffs.html.haml
+3
-3
No files found.
app/controllers/projects/blame_controller.rb
View file @
970d86b7
...
...
@@ -8,7 +8,7 @@ class Projects::BlameController < Projects::ApplicationController
before_filter
:require_non_empty_project
def
show
@blob
=
Gitlab
::
Git
::
Blob
.
find
(
@repository
,
@commit
.
id
,
@path
)
@blob
=
@repository
.
blob_at
(
@commit
.
id
,
@path
)
@blame
=
Gitlab
::
Git
::
Blame
.
new
(
project
.
repository
,
@commit
.
id
,
@path
)
end
end
app/controllers/projects/blob_controller.rb
View file @
970d86b7
...
...
@@ -8,7 +8,7 @@ class Projects::BlobController < Projects::ApplicationController
before_filter
:require_non_empty_project
def
show
@blob
=
Gitlab
::
Git
::
Blob
.
find
(
@repository
,
@commit
.
id
,
@path
)
@blob
=
@repository
.
blob_at
(
@commit
.
id
,
@path
)
not_found!
unless
@blob
end
...
...
app/controllers/projects/edit_tree_controller.rb
View file @
970d86b7
...
...
@@ -10,7 +10,7 @@ class Projects::EditTreeController < Projects::ApplicationController
before_filter
:edit_requirements
,
only:
[
:show
,
:update
]
def
show
@last_commit
=
Gitlab
::
Git
::
Commit
.
last_for_path
(
@
project
.
repository
,
@ref
,
@path
).
sha
@last_commit
=
Gitlab
::
Git
::
Commit
.
last_for_path
(
@repository
,
@ref
,
@path
).
sha
end
def
update
...
...
@@ -32,7 +32,7 @@ class Projects::EditTreeController < Projects::ApplicationController
private
def
edit_requirements
@blob
=
Gitlab
::
Git
::
Blob
.
find
(
@repository
,
@commit
.
id
,
@path
)
@blob
=
@repository
.
blob_at
(
@commit
.
id
,
@path
)
unless
@blob
redirect_to
project_blob_path
(
@project
,
@id
),
notice:
"You can only edit text files"
...
...
app/controllers/projects/raw_controller.rb
View file @
970d86b7
...
...
@@ -8,7 +8,7 @@ class Projects::RawController < Projects::ApplicationController
before_filter
:require_non_empty_project
def
show
@blob
=
Gitlab
::
Git
::
Blob
.
find
(
@repository
,
@commit
.
id
,
@path
)
@blob
=
@repository
.
blob_at
(
@commit
.
id
,
@path
)
if
@blob
type
=
if
@blob
.
mime_type
=~
/html|javascript/
...
...
app/helpers/blobs_helper.rb
deleted
100644 → 0
View file @
68d89548
module
BlobsHelper
def
find_blob
(
repository
,
sha
,
path
)
Gitlab
::
Git
::
Blob
.
find
(
repository
,
sha
,
path
)
end
end
app/models/repository.rb
View file @
970d86b7
...
...
@@ -155,4 +155,8 @@ class Repository
super
end
def
blob_at
(
sha
,
path
)
Gitlab
::
Git
::
Blob
.
find
(
self
,
sha
,
path
)
end
end
app/views/projects/commits/_diffs.html.haml
View file @
970d86b7
...
...
@@ -37,8 +37,8 @@
-
unless
@suppress_diff
-
diffs
.
each_with_index
do
|
diff
,
i
|
-
next
if
diff
.
diff
.
empty?
-
file
=
find_blob
(
project
.
repository
,
@commit
.
id
,
diff
.
new_path
)
-
file
=
find_blob
(
project
.
repository
,
@commit
.
parent_id
,
diff
.
old_path
)
unless
file
-
file
=
project
.
repository
.
blob_at
(
@commit
.
id
,
diff
.
new_path
)
-
file
=
project
.
repository
.
blob_at
(
@commit
.
parent_id
,
diff
.
old_path
)
unless
file
-
next
unless
file
.file
{
id:
"diff-#{i}"
}
.header
...
...
@@ -64,7 +64,7 @@
-
if
file
.
text?
=
render
"projects/commits/text_file"
,
diff:
diff
,
index:
i
-
elsif
file
.
image?
-
old_file
=
find_blob
(
project
.
repository
,
@commit
.
parent_id
,
diff
.
old_path
)
if
@commit
.
parent_id
-
old_file
=
project
.
repository
.
blob_at
(
@commit
.
parent_id
,
diff
.
old_path
)
if
@commit
.
parent_id
=
render
"projects/commits/image"
,
diff:
diff
,
old_file:
old_file
,
file:
file
,
index:
i
-
else
%p
.nothing_here_message
No preview for this file type
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment