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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
d74d7c7c
Commit
d74d7c7c
authored
Apr 15, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update app code to use Gitlab::Git::Diff
parent
6a4a17f3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
4 deletions
+19
-4
app/models/note.rb
app/models/note.rb
+3
-3
lib/gitlab/git/commit.rb
lib/gitlab/git/commit.rb
+5
-1
lib/gitlab/git/repository.rb
lib/gitlab/git/repository.rb
+11
-0
No files found.
app/models/note.rb
View file @
d74d7c7c
...
@@ -68,8 +68,8 @@ class Note < ActiveRecord::Base
...
@@ -68,8 +68,8 @@ class Note < ActiveRecord::Base
def
diff
def
diff
if
noteable
.
diffs
.
present?
if
noteable
.
diffs
.
present?
noteable
.
diffs
.
select
do
|
d
|
noteable
.
diffs
.
select
do
|
d
|
if
d
.
b
_path
if
d
.
new
_path
Digest
::
SHA1
.
hexdigest
(
d
.
b
_path
)
==
diff_file_index
Digest
::
SHA1
.
hexdigest
(
d
.
new
_path
)
==
diff_file_index
end
end
end
.
first
end
.
first
end
end
...
@@ -80,7 +80,7 @@ class Note < ActiveRecord::Base
...
@@ -80,7 +80,7 @@ class Note < ActiveRecord::Base
end
end
def
diff_file_name
def
diff_file_name
diff
.
b
_path
diff
.
new
_path
end
end
def
diff_new_line
def
diff_new_line
...
...
lib/gitlab/git/commit.rb
View file @
d74d7c7c
...
@@ -9,7 +9,7 @@ module Gitlab
...
@@ -9,7 +9,7 @@ module Gitlab
:author_name
,
:author_email
,
:parent_ids
,
:author_name
,
:author_email
,
:parent_ids
,
:committer_name
,
:committer_email
:committer_name
,
:committer_email
delegate
:parents
,
:
diffs
,
:
tree
,
:stats
,
:to_patch
,
delegate
:parents
,
:tree
,
:stats
,
:to_patch
,
to: :raw_commit
to: :raw_commit
def
initialize
(
raw_commit
,
head
=
nil
)
def
initialize
(
raw_commit
,
head
=
nil
)
...
@@ -96,6 +96,10 @@ module Gitlab
...
@@ -96,6 +96,10 @@ module Gitlab
committed_date
committed_date
end
end
def
diffs
raw_commit
.
diffs
.
map
{
|
diff
|
Gitlab
::
Git
::
Diff
.
new
(
diff
)
}
end
private
private
def
init_from_grit
(
grit
)
def
init_from_grit
(
grit
)
...
...
lib/gitlab/git/repository.rb
View file @
d74d7c7c
...
@@ -191,6 +191,17 @@ module Gitlab
...
@@ -191,6 +191,17 @@ module Gitlab
"
#{
type
}
:
#{
path_with_namespace
}
"
"
#{
type
}
:
#{
path_with_namespace
}
"
end
end
def
diffs_between
(
source_branch
,
target_branch
)
# Only show what is new in the source branch compared to the target branch, not the other way around.
# The linex below with merge_base is equivalent to diff with three dots (git diff branch1...branch2)
# From the git documentation: "git diff A...B" is equivalent to "git diff $(git-merge-base A B) B"
common_commit
=
repo
.
git
.
native
(
:merge_base
,
{},
[
target_branch
,
source_branch
]).
strip
repo
.
diff
(
common_commit
,
source_branch
).
map
{
|
diff
|
Gitlab
::
Git
::
Diff
.
new
(
diff
)
}
rescue
Grit
::
Git
::
GitTimeout
[
Gitlab
::
Git
::
Diff
::
BROKEN_DIFF
]
end
protected
protected
def
decorate_commit
(
commit
,
ref
=
nil
)
def
decorate_commit
(
commit
,
ref
=
nil
)
...
...
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