Skip to content
Snippets Groups Projects
Commit 3e01385b authored by Lin Jen-Shin's avatar Lin Jen-Shin
Browse files

Should pass branch name, not commit object!

parent bb9d3059
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -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
 
Loading
Loading
@@ -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
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment