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
c93db5d2
Commit
c93db5d2
authored
Oct 09, 2018
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve scripts/ee_specific_check/ee_specific_check.rb
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
3d4f71f1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
77 additions
and
17 deletions
+77
-17
scripts/ee_specific_check/ee_specific_check.rb
scripts/ee_specific_check/ee_specific_check.rb
+77
-17
No files found.
scripts/ee_specific_check/ee_specific_check.rb
View file @
c93db5d2
...
...
@@ -277,7 +277,9 @@ module EESpecificCheck
def
matching_ce_refs
@matching_ce_refs
||=
run_git_command
(
"ls-remote
#{
ce_repo_url
}
\"
*
#{
minimal_ce_branch_name
}
*
\"
"
)
.
scan
(
%r{(?<=refs/heads/|refs/tags/).+}
).
sort_by
(
&
:size
)
.
scan
(
%r{(?<=refs/heads/|refs/tags/).+}
)
.
select
{
|
branch
|
branch
.
match?
(
/\b
#{
minimal_ce_branch_name
}
\b/i
)
}
.
sort_by
(
&
:size
)
end
def
scan_diff_numstat
(
numstat
)
...
...
@@ -312,47 +314,105 @@ if $0 == __FILE__
require
'rspec/autorun'
RSpec
.
describe
EESpecificCheck
do
subject
{
Class
.
new
{
include
EESpecificCheck
}.
new
}
before
do
extend
EESpecificCheck
allow
(
subject
).
to
receive
(
:warn
)
allow
(
self
).
to
receive
(
:warn
)
EESpecificCheck
.
private_instance_methods
.
each
do
|
name
|
subject
.
class
.
__send__
(
:public
,
name
)
# rubocop:disable GitlabSecurity/PublicSend
end
end
describe
'.run_git_command'
do
# rubocop: disable CodeReuse/ActiveRecord
it
'returns the single output when there is a single command'
do
output
=
run_git_command
(
'status'
)
output
=
subject
.
run_git_command
(
'status'
)
expect
(
output
).
to
be_kind_of
(
String
)
expect
(
s
elf
).
to
have_received
(
:warn
).
with
(
/git status/
)
expect
(
s
ubject
).
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
=
run_git_command
(
'status'
,
'help'
)
output
=
subject
.
run_git_command
(
'status'
,
'help'
)
expect
(
output
).
to
all
(
be_a
(
String
))
expect
(
s
elf
).
to
have_received
(
:warn
).
with
(
/git status/
)
expect
(
s
elf
).
to
have_received
(
:warn
).
with
(
/git help/
)
expect
(
s
ubject
).
to
have_received
(
:warn
).
with
(
/git status/
)
expect
(
s
ubject
).
to
have_received
(
:warn
).
with
(
/git help/
)
end
# rubocop: enable CodeReuse/ActiveRecord
end
describe
'.matching_ce_refs'
do
before
do
expect
(
self
).
to
receive
(
:current_branch
).
and_return
(
'v9'
)
expect
(
self
).
to
receive
(
:run_git_command
)
.
and_return
(
<<~
OUTPUT
)
d6602ec5194c87b0fc87103ca4d67251c76f233a
\t
refs/tags/v9
f25a265a342aed6041ab0cc484224d9ca54b6f41
\t
refs/tags/v9.12
c5db5456ae3b0873fc659c19fafdde22313cc441
\t
refs/tags/v9.123
0918385dbd9656cab0d1d81ba7453d49bbc16250
\t
refs/heads/v9.x
expect
(
subject
).
to
receive
(
:current_branch
).
and_return
(
ee_branch
)
expect
(
subject
).
to
receive
(
:run_git_command
)
.
and_return
(
ls_remote_output
)
end
describe
'simple cases'
do
let
(
:ls_remote_output
)
do
<<~
OUTPUT
d6602ec5194c87b0fc87103ca4d67251c76f233a
\t
refs/tags/v9
f25a265a342aed6041ab0cc484224d9ca54b6f41
\t
refs/tags/v9.12
c5db5456ae3b0873fc659c19fafdde22313cc441
\t
refs/tags/v9.123
0918385dbd9656cab0d1d81ba7453d49bbc16250
\t
refs/heads/v9.x
28862662b749fe981386814e2dba87b0e72c1eab
\t
refs/remotes/remote_mirror_3059/v9-to-fix-http-case-problems
5e3496802098c86050c5b463507f3a68a83a9f02
\t
refs/remotes/remote_mirror_3059/29036-use-slack-service-v9
OUTPUT
end
context
'with a ee- prefix'
do
let
(
:ee_branch
)
{
'ee-v9'
}
it
'sorts by matching size'
do
expect
(
subject
.
matching_ce_refs
).
to
eq
(
%w[v9 v9.x v9.12 v9.123]
)
end
end
context
'with a -ee suffix'
do
let
(
:ee_branch
)
{
'v9-ee'
}
it
'sorts by matching size'
do
expect
(
subject
.
matching_ce_refs
).
to
eq
(
%w[v9 v9.x v9.12 v9.123]
)
end
end
end
it
'sorts by matching size'
do
expect
(
matching_ce_refs
).
to
eq
(
%w[v9 v9.x v9.12 v9.123]
)
describe
'with ambiguous branch name'
do
let
(
:ls_remote_output
)
do
<<~
OUTPUT
954d7119384c9f2a3c862bac97beb641eb8755d6
\t
refs/heads/feature/sm/35954-expand-kubernetesservice-to-use-username-password
954d7119384c9f2a3c862bac97beb641eb8755d6
\t
refs/heads/ce-to-ee-231
954d7119384c9f2a3c862bac97beb641eb8755d6
\t
refs/heads/ce-to-ee-2
954d7119384c9f2a3c862bac97beb641eb8755d6
\t
refs/heads/ce-to-1
954d7119384c9f2a3c862bac97beb641eb8755d6
\t
refs/heads/ee-to-ce-123
954d7119384c9f2a3c862bac97beb641eb8755d6
\t
refs/heads/ee-to-ce-12
954d7119384c9f2a3c862bac97beb641eb8755d6
\t
refs/heads/to-ce-1
28862662b749fe981386814e2dba87b0e72c1eab
\t
refs/remotes/remote_mirror_3059/27056-upgrade-vue-resource-to-1-0-3-to-fix-http-case-problems
5e3496802098c86050c5b463507f3a68a83a9f02
\t
refs/remotes/remote_mirror_3059/29036-use-slack-service-to-notify-of-failed-pipelines
OUTPUT
end
context
'with a ee- prefix'
do
let
(
:ee_branch
)
{
'ee-to-ce'
}
let
(
:minimal_ce_branch
)
{
'to-ce'
}
it
'sorts by matching size'
do
expect
(
subject
.
matching_ce_refs
).
to
eq
(
%w[to-ce-1 ee-to-ce-12 ee-to-ce-123]
)
end
end
context
'with a -ee suffix'
do
let
(
:ee_branch
)
{
'ce-to-ee'
}
let
(
:minimal_ce_branch
)
{
'ce-to'
}
it
'sorts by matching size'
do
expect
(
subject
.
matching_ce_refs
).
to
eq
(
%w[ce-to-1 ce-to-ee-2 ce-to-ee-231]
)
end
end
end
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