BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
3e01385b
Commit
3e01385b
authored
Dec 10, 2016
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Should pass branch name, not commit object!
parent
bb9d3059
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
5 deletions
+6
-5
compare_service.rb
app/services/compare_service.rb
+6
-5
No files found.
app/services/compare_service.rb
View file @
3e01385b
...
...
@@ -3,15 +3,16 @@ require 'securerandom'
# Compare 2 branches for one repo or between repositories
# and return Gitlab::Git::Compare object that responds to commits and diffs
class
CompareService
attr_reader
:source_project
,
:source_branch
attr_reader
:source_project
,
:source_branch
_name
def
initialize
(
new_source_project
,
source_branch_name
)
def
initialize
(
new_source_project
,
new_
source_branch_name
)
@source_project
=
new_source_project
@source_branch
=
new_source_project
.
commit
(
source_branch_name
)
@source_branch
_name
=
new_source_branch_name
end
def
execute
(
target_project
,
target_branch
,
straight:
false
)
source_sha
=
source_branch
.
try
(
:sha
)
source_sha
=
source_project
.
repository
.
commit
(
source_branch_name
).
try
(
:sha
)
return
unless
source_sha
...
...
@@ -20,7 +21,7 @@ class CompareService
compare
(
source_sha
,
target_project
,
target_branch
,
straight
)
else
target_project
.
repository
.
with_tmp_ref
(
source_project
.
repository
,
source_branch
)
do
source_project
.
repository
,
source_branch
_name
)
do
compare
(
source_sha
,
target_project
,
target_branch
,
straight
)
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