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
246faa3d
Commit
246faa3d
authored
Nov 22, 2012
by
Riyad Preukschas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Commit#to_diff for raw diff
parent
8b401039
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
0 deletions
+15
-0
app/models/commit.rb
app/models/commit.rb
+15
-0
No files found.
app/models/commit.rb
View file @
246faa3d
...
@@ -150,4 +150,19 @@ class Commit
...
@@ -150,4 +150,19 @@ class Commit
def
parents_count
def
parents_count
parents
&&
parents
.
count
||
0
parents
&&
parents
.
count
||
0
end
end
# Shows the diff between the commit's parent and the commit.
#
# Cuts out the header and stats from #to_patch and returns only the diff.
def
to_diff
# see Grit::Commit#show
patch
=
to_patch
# discard lines before the diff
lines
=
patch
.
split
(
"
\n
"
)
while
!
lines
.
first
.
start_with?
(
"diff --git"
)
do
lines
.
shift
end
lines
.
join
(
"
\n
"
)
end
end
end
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