rid of previous changes

parent 53eb685c
# frozen_string_literal: true
require 'pry'
require_relative 'lib/release_tools'
require_relative 'lib/release_tools/support/tasks_helper'
......
......@@ -21,7 +21,7 @@ module ReleaseTools
merge = UpstreamMerge.new(
origin: Project::GitlabEe.remotes[:gitlab],
upstream: Project::GitlabCe.remotes[:gitlab],
source_branch: upstream_merge_request.source_branch
merge_branch: upstream_merge_request.source_branch
)
upstream_merge_request.conflicts = merge.execute!
......
......@@ -2,18 +2,17 @@
module ReleaseTools
class UpstreamMerge
attr_reader :origin, :upstream, :source_branch, :target_branch
attr_reader :origin, :upstream, :merge_branch
CONFLICT_MARKER_REGEX = /\A(?<conflict_type>[ADU]{2}) /.freeze
DownstreamAlreadyUpToDate = Class.new(StandardError)
PushFailed = Class.new(StandardError)
def initialize(origin:, upstream:, source_branch:, target_branch: 'master')
def initialize(origin:, upstream:, merge_branch:)
@origin = origin
@upstream = upstream
@source_branch = source_branch
@target_branch = target_branch
@merge_branch = merge_branch
end
def execute!
......@@ -25,15 +24,10 @@ module ReleaseTools
conflicts
end
def dry_run
setup_merge_drivers
prepare_upstream_merge
end
private
def repository
@repository ||= RemoteRepository.get({ origin: origin, upstream: upstream }, global_depth: nil)
@repository ||= RemoteRepository.get({ origin: origin, upstream: upstream }, global_depth: 200)
end
def setup_merge_drivers
......@@ -47,14 +41,13 @@ module ReleaseTools
def prepare_upstream_merge
$stdout.puts "Prepare repository...".colorize(:green)
# We fetch CE first to make sure our EE copy is more up-to-date!
repository.fetch(target_branch, remote: :upstream)
repository.fetch(target_branch, remote: :origin)
repository.ensure_branch_exists(source_branch)
repository.configure_upstream_to(target_branch)
repository.fetch('master', remote: :upstream)
repository.fetch('master', remote: :origin)
repository.checkout_new_branch(merge_branch, base: 'origin/master')
end
def execute_upstream_merge
result = repository.merge("upstream/#{target_branch}", source_branch, no_ff: true)
result = repository.merge('upstream/master', merge_branch, no_ff: true)
# Depending on Git version, it's "up-to-date" or "up to date"...
raise DownstreamAlreadyUpToDate if result.output =~ /\AAlready up[\s\-]to[\s\-]date/
......@@ -68,7 +61,7 @@ module ReleaseTools
add_latest_modifier_to_conflicts(conflicts)
end
raise PushFailed unless repository.push(origin, source_branch)
raise PushFailed unless repository.push(origin, merge_branch)
conflicts
end
......
......@@ -20,7 +20,7 @@ describe ReleaseTools::Services::UpstreamMergeService do
.with(
origin: ReleaseTools::Project::GitlabEe.remotes[:gitlab],
upstream: ReleaseTools::Project::GitlabCe.remotes[:gitlab],
source_branch: 'ce-to-ee-2017-11-15'
merge_branch: 'ce-to-ee-2017-11-15'
).and_return(upstream_merge)
end
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment