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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
ac26b237
Commit
ac26b237
authored
Jul 06, 2016
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove duplication, unused methods, and some other style things
parent
2db75f8d
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
14 additions
and
18 deletions
+14
-18
app/helpers/diff_helper.rb
app/helpers/diff_helper.rb
+3
-1
app/models/concerns/note_on_diff.rb
app/models/concerns/note_on_diff.rb
+0
-2
app/models/merge_request.rb
app/models/merge_request.rb
+1
-5
app/views/projects/diffs/_diffs.html.haml
app/views/projects/diffs/_diffs.html.haml
+1
-1
lib/gitlab/diff/file.rb
lib/gitlab/diff/file.rb
+3
-4
lib/gitlab/diff/highlight.rb
lib/gitlab/diff/highlight.rb
+6
-5
No files found.
app/helpers/diff_helper.rb
View file @
ac26b237
...
...
@@ -89,6 +89,8 @@ module DiffHelper
end
def
commit_for_diff
(
diff_file
)
return
diff_file
.
content_commit
if
diff_file
.
content_commit
if
diff_file
.
deleted_file
@base_commit
||
@commit
.
parent
||
@commit
else
...
...
@@ -97,7 +99,7 @@ module DiffHelper
end
def
diff_file_html_data
(
project
,
diff_file
)
commit
=
diff_file
.
content_commit
||
commit_for_diff
(
diff_file
)
commit
=
commit_for_diff
(
diff_file
)
{
blob_diff_path:
namespace_project_blob_diff_path
(
project
.
namespace
,
project
,
tree_join
(
commit
.
id
,
diff_file
.
file_path
))
...
...
app/models/concerns/note_on_diff.rb
View file @
ac26b237
...
...
@@ -33,13 +33,11 @@ module NoteOnDiff
# Returns an array of at most 16 highlighted lines above a diff note
def
truncated_diff_lines
prev_match_line
=
nil
prev_lines
=
[]
highlighted_diff_lines
.
each
do
|
line
|
if
line
.
meta?
prev_lines
.
clear
prev_match_line
=
line
else
prev_lines
<<
line
...
...
app/models/merge_request.rb
View file @
ac26b237
...
...
@@ -164,10 +164,6 @@ class MergeRequest < ActiveRecord::Base
merge_request_diff
?
merge_request_diff
.
first_commit
:
compare_commits
.
first
end
def
last_commit
merge_request_diff
?
merge_request_diff
.
last_commit
:
compare_commits
.
last
end
def
diff_size
merge_request_diff
.
size
end
...
...
@@ -246,7 +242,7 @@ class MergeRequest < ActiveRecord::Base
end
def
diff_refs
return
nil
unless
diff_start_commit
||
diff_base_commit
return
unless
diff_start_commit
||
diff_base_commit
Gitlab
::
Diff
::
DiffRefs
.
new
(
base_sha:
diff_base_sha
,
...
...
app/views/projects/diffs/_diffs.html.haml
View file @
ac26b237
...
...
@@ -23,7 +23,7 @@
.files
-
diff_files
.
each_with_index
do
|
diff_file
,
index
|
-
diff_commit
=
diff_file
.
content_commit
||
commit_for_diff
(
diff_file
)
-
diff_commit
=
commit_for_diff
(
diff_file
)
-
blob
=
diff_file
.
blob
(
diff_commit
)
-
next
unless
blob
-
blob
.
load_all_data!
(
project
.
repository
)
unless
blob
.
only_display_raw?
...
...
lib/gitlab/diff/file.rb
View file @
ac26b237
...
...
@@ -21,9 +21,7 @@ module Gitlab
new_path:
new_path
,
old_line:
line
.
old_line
,
new_line:
line
.
new_line
,
base_sha:
diff_refs
.
base_sha
,
start_sha:
diff_refs
.
start_sha
,
head_sha:
diff_refs
.
head_sha
diff_refs:
diff_refs
)
end
...
...
@@ -53,7 +51,7 @@ module Gitlab
def
content_commit
return
unless
diff_refs
repository
.
commit
(
deleted_file
?
old_ref
:
new_ref
)
end
...
...
@@ -121,6 +119,7 @@ module Gitlab
def
blob
(
commit
=
content_commit
)
return
unless
commit
repository
.
blob_at
(
commit
.
id
,
file_path
)
end
end
...
...
lib/gitlab/diff/highlight.rb
View file @
ac26b237
...
...
@@ -42,11 +42,12 @@ module Gitlab
line_prefix
=
diff_line
.
text
.
match
(
/\A(.)/
)
?
$1
:
' '
if
diff_line
.
unchanged?
||
diff_line
.
added?
rich_line
=
new_lines
[
diff_line
.
new_pos
-
1
]
elsif
diff_line
.
removed?
rich_line
=
old_lines
[
diff_line
.
old_pos
-
1
]
end
rich_line
=
if
diff_line
.
unchanged?
||
diff_line
.
added?
new_lines
[
diff_line
.
new_pos
-
1
]
elsif
diff_line
.
removed?
old_lines
[
diff_line
.
old_pos
-
1
]
end
# Only update text if line is found. This will prevent
# issues with submodules given the line only exists in diff content.
...
...
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