Commit 54533920 authored by Rémy Coutable's avatar Rémy Coutable

Always fetch master from the canonical remote

This way, if a fork's master branch is far behind the canonical's
master, it won't use the tip of the fork's master branch as merge base
and thus won't create a huge and wrong patch file.
Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent a4072db0
...@@ -193,7 +193,7 @@ module Gitlab ...@@ -193,7 +193,7 @@ module Gitlab
# Repository is initially cloned with a depth of 20 so we need to fetch # Repository is initially cloned with a depth of 20 so we need to fetch
# deeper in the case the branch has more than 20 commits on top of master # deeper in the case the branch has more than 20 commits on top of master
fetch(branch: branch, depth: depth) fetch(branch: branch, depth: depth)
fetch(branch: 'master', depth: depth) fetch(branch: 'master', depth: depth, remote: DEFAULT_CE_PROJECT_URL)
merge_base_found? merge_base_found?
end end
...@@ -201,10 +201,10 @@ module Gitlab ...@@ -201,10 +201,10 @@ module Gitlab
raise "\n#{branch} is too far behind master, please rebase it!\n" unless success raise "\n#{branch} is too far behind master, please rebase it!\n" unless success
end end
def fetch(branch:, depth:) def fetch(branch:, depth:, remote: 'origin')
step( step(
"Fetching deeper...", "Fetching deeper...",
%W[git fetch --depth=#{depth} --prune origin +refs/heads/#{branch}:refs/remotes/origin/#{branch}] %W[git fetch --depth=#{depth} --prune #{remote} +refs/heads/#{branch}:refs/remotes/origin/#{branch}]
) do |output, status| ) do |output, status|
raise "Fetch failed: #{output}" unless status.zero? raise "Fetch failed: #{output}" unless status.zero?
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