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
Boxiang Sun
gitlab-ce
Commits
228d2a4c
Commit
228d2a4c
authored
Jul 06, 2016
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add some more code comments.
parent
d9c75aec
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
3 deletions
+20
-3
app/models/concerns/note_on_diff.rb
app/models/concerns/note_on_diff.rb
+1
-0
app/models/merge_request.rb
app/models/merge_request.rb
+3
-2
lib/gitlab/diff/diff_refs.rb
lib/gitlab/diff/diff_refs.rb
+10
-0
lib/gitlab/diff/line_mapper.rb
lib/gitlab/diff/line_mapper.rb
+1
-1
lib/gitlab/diff/position.rb
lib/gitlab/diff/position.rb
+5
-0
No files found.
app/models/concerns/note_on_diff.rb
View file @
228d2a4c
...
@@ -31,6 +31,7 @@ module NoteOnDiff
...
@@ -31,6 +31,7 @@ module NoteOnDiff
false
false
end
end
# Returns an array of at most 16 highlighted lines above a diff note
def
truncated_diff_lines
def
truncated_diff_lines
prev_match_line
=
nil
prev_match_line
=
nil
prev_lines
=
[]
prev_lines
=
[]
...
...
app/models/merge_request.rb
View file @
228d2a4c
...
@@ -186,8 +186,9 @@ class MergeRequest < ActiveRecord::Base
...
@@ -186,8 +186,9 @@ class MergeRequest < ActiveRecord::Base
# This will not be the actual base commit if the target branch was merged into
# This will not be the actual base commit if the target branch was merged into
# the source branch after the merge request was created, but it is good enough
# the source branch after the merge request was created, but it is good enough
# for the specific purpose of linking to a commit.
# for the specific purpose of linking to a commit.
# It is not good enough for use in Gitlab::Git::DiffRefs, which need the
# It is not good enough for use in `Gitlab::Git::DiffRefs`, which needs the
# true base commit.
# true base commit, so we can't simply have `#diff_base_commit` fall back on
# this method.
def
likely_diff_base_commit
def
likely_diff_base_commit
first_commit
.
parent
||
first_commit
first_commit
.
parent
||
first_commit
end
end
...
...
lib/gitlab/diff/diff_refs.rb
View file @
228d2a4c
...
@@ -18,6 +18,16 @@ module Gitlab
...
@@ -18,6 +18,16 @@ module Gitlab
head_sha
==
other
.
head_sha
head_sha
==
other
.
head_sha
end
end
# There is only one case in which we will have `start_sha` and `head_sha`,
# but not `base_sha`, which is when a diff is generated between an
# orphaned branch and another branch, which means there _is_ no base, but
# we're still able to highlight it, and to create diff notes, which are
# the primary things `DiffRefs` are used for.
# `DiffRefs` are "complete" when they have `start_sha` and `head_sha`,
# because `base_sha` can always be derived from this, to return an actual
# sha, or `nil`.
# We have `base_sha` directly available on `DiffRefs` because it's faster#
# than having to look it up in the repo every time.
def
complete?
def
complete?
start_sha
&&
head_sha
start_sha
&&
head_sha
end
end
...
...
lib/gitlab/diff/line_mapper.rb
View file @
228d2a4c
...
@@ -26,7 +26,7 @@ module Gitlab
...
@@ -26,7 +26,7 @@ module Gitlab
@diff_lines
||=
@diff_file
.
diff_lines
@diff_lines
||=
@diff_file
.
diff_lines
end
end
# Find old
line number based on new
line number.
# Find old
/new line number based on its old/new counterpart
line number.
def
map_line_number
(
from_line
,
from
:,
to
:)
def
map_line_number
(
from_line
,
from
:,
to
:)
# If no diff file could be found, the file wasn't changed, and the
# If no diff file could be found, the file wasn't changed, and the
# mapped line number is the same as the specified line number.
# mapped line number is the same as the specified line number.
...
...
lib/gitlab/diff/position.rb
View file @
228d2a4c
...
@@ -28,6 +28,11 @@ module Gitlab
...
@@ -28,6 +28,11 @@ module Gitlab
end
end
end
end
# `Gitlab::Diff::Position` objects are stored as serialized attributes in
# `DiffNote`, which use YAML to encode and decode objects.
# `#init_with` and `#encode_with` can be used to customize the en/decoding
# behavior. In this case, we override these to prevent memoized instance
# variables like `@diff_file` and `@diff_line` from being serialized.
def
init_with
(
coder
)
def
init_with
(
coder
)
initialize
(
coder
[
'attributes'
])
initialize
(
coder
[
'attributes'
])
...
...
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