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
75ac1c70
Commit
75ac1c70
authored
Jan 10, 2019
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fail and ask people to run ee checks locally when
The merge base cannot be found.
parent
9eadb163
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
7 deletions
+58
-7
scripts/ee_specific_check/ee_specific_check.rb
scripts/ee_specific_check/ee_specific_check.rb
+58
-7
No files found.
scripts/ee_specific_check/ee_specific_check.rb
View file @
75ac1c70
# frozen_string_literal: true
# rubocop: disable CodeReuse/ActiveRecord
module
EESpecificCheck
WHITELIST
=
[
...
...
@@ -31,9 +32,9 @@ module EESpecificCheck
ce_fetch_head
=
fetch_remote_ce_branch
ee_fetch_head
=
head_commit_sha
ce_fetch_base
=
run_git_command
(
"merge-base canonical-ce/master
#{
ce_fetch_head
}
"
)
ee_fetch_base
=
run_git_command
(
"merge-base canonical-ee/master HEAD"
)
ce_merge_base
=
run_git_command
(
"merge-base
#{
ce_fetch_head
}
#{
ee_fetch_head
}
"
)
ce_fetch_base
=
find_merge_base
(
'canonical-ce/master'
,
ce_fetch_head
)
ee_fetch_base
=
find_merge_base
(
'canonical-ee/master'
,
'HEAD'
)
ce_merge_base
=
find_merge_base
(
ce_fetch_head
,
ee_fetch_head
)
ce_updated_head
=
find_ce_compare_head
(
ce_fetch_head
,
ce_fetch_base
,
ce_merge_base
)
...
...
@@ -60,6 +61,28 @@ module EESpecificCheck
"
#{
remote_to_fetch
}
/
#{
branch_to_fetch
}
"
end
def
find_merge_base
(
left
,
right
)
merge_base
=
run_git_command
(
"merge-base
#{
left
}
#{
right
}
"
)
return
merge_base
unless
merge_base
.
empty?
say
<<~
MESSAGE
💥 Unfortunately we cannot find the merge-base for
#{
left
}
and
#{
right
}
,
💥 and we'll try to fix that in:
https://gitlab.com/gitlab-org/gitlab-ee/issues/9120
💥 Before that, please run this job locally as a workaround:
./scripts/ee-specific-lines-check
💥 And paste the result as a discussion to show it to the maintainer.
💥 If you have any questions, please ping @godfat to investigate and
💥 clarify.
MESSAGE
exit
(
253
)
end
def
find_ce_compare_head
(
ce_fetch_head
,
ce_fetch_base
,
ce_merge_base
)
if
git_ancestor?
(
ce_merge_base
,
ce_fetch_base
)
say
(
"CE is ahead of EE, finding backward CE head"
)
...
...
@@ -319,16 +342,13 @@ if $0 == __FILE__
end
describe
'.run_git_command'
do
# rubocop: disable CodeReuse/ActiveRecord
it
'returns the single output when there is a single command'
do
output
=
subject
.
run_git_command
(
'status'
)
expect
(
output
).
to
be_kind_of
(
String
)
expect
(
subject
).
to
have_received
(
:warn
).
with
(
/git status/
)
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
it
'returns an array of output for more commands'
do
output
=
subject
.
run_git_command
(
'status'
,
'help'
)
...
...
@@ -336,7 +356,38 @@ if $0 == __FILE__
expect
(
subject
).
to
have_received
(
:warn
).
with
(
/git status/
)
expect
(
subject
).
to
have_received
(
:warn
).
with
(
/git help/
)
end
# rubocop: enable CodeReuse/ActiveRecord
end
describe
'.find_merge_base'
do
context
'when it cannot find the merge base'
do
before
do
allow
(
subject
).
to
receive
(
:say
)
allow
(
subject
).
to
receive
(
:exit
)
expect
(
subject
).
to
receive
(
:run_git_command
).
and_return
(
''
)
end
it
'calls exit(253) to fail the job and ask run it locally'
do
subject
.
find_merge_base
(
'master'
,
'HEAD'
)
expect
(
subject
).
to
have_received
(
:say
)
.
with
(
Regexp
.
union
(
'./scripts/ee-specific-lines-check'
))
expect
(
subject
).
to
have_received
(
:exit
)
.
with
(
253
)
end
end
context
'when it found the merge base'
do
before
do
expect
(
subject
).
to
receive
(
:run_git_command
).
and_return
(
'deadbeef'
)
end
it
'returns the found merge base'
do
output
=
subject
.
find_merge_base
(
'master'
,
'HEAD'
)
expect
(
output
).
to
eq
(
'deadbeef'
)
end
end
end
describe
'.matching_ce_refs'
do
...
...
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