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
955d0cae
Commit
955d0cae
authored
Jun 07, 2018
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Spell out all the words when matching ls-remote
Use this regular expression: %r{(?<=refs/heads/|refs/tags/).+}
parent
a4b2d939
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
10 deletions
+31
-10
scripts/ee_specific_check/ee_specific_check.rb
scripts/ee_specific_check/ee_specific_check.rb
+31
-10
No files found.
scripts/ee_specific_check/ee_specific_check.rb
View file @
955d0cae
...
...
@@ -167,11 +167,9 @@ module EESpecificCheck
end
def
find_remote_ce_branch
ls_remote_output
=
run_git_command
(
"ls-remote
#{
ce_repo_url
}
\"
*
#{
minimal_ce_branch_name
}
*
\"
"
)
if
ls_remote_output
.
include?
(
minimal_ce_branch_name
)
branch_to_fetch
=
ls_remote_output
.
scan
(
%r{(?<=refs/heads/|tags/).+}
).
sort_by
(
&
:size
).
first
branch_to_fetch
=
matching_ce_refs
.
first
if
branch_to_fetch
say
"💪 We found the branch '
#{
branch_to_fetch
}
' in the
#{
ce_repo_url
}
repository. We will fetch it."
run_git_command
(
"remote add target-ce
#{
ce_repo_url
}
"
)
...
...
@@ -199,6 +197,12 @@ module EESpecificCheck
@minimal_ce_branch_name
||=
current_branch
.
sub
(
/(\Aee\-|\-ee\z)/
,
''
)
end
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
)
end
def
scan_diff_numstat
(
numstat
)
numstat
.
scan
(
/(\d+)\s+(\d+)\s+(.+)/
)
.
each_with_object
({})
do
|
(
added
,
deleted
,
file
),
result
|
...
...
@@ -231,10 +235,10 @@ if $0 == __FILE__
require
'rspec/autorun'
RSpec
.
describe
EESpecificCheck
do
include
EESpecificCheck
before
do
allow
(
self
).
to
receive
(
:puts
)
extend
EESpecificCheck
allow
(
self
).
to
receive
(
:warn
)
end
describe
'.run_git_command'
do
...
...
@@ -242,15 +246,32 @@ if $0 == __FILE__
output
=
run_git_command
(
'status'
)
expect
(
output
).
to
be_kind_of
(
String
)
expect
(
self
).
to
have_received
(
:
puts
).
with
(
/git status/
)
expect
(
self
).
to
have_received
(
:
warn
).
with
(
/git status/
)
end
it
'returns an array of output for more commands'
do
output
=
run_git_command
(
'status'
,
'help'
)
expect
(
output
).
to
all
(
be_a
(
String
))
expect
(
self
).
to
have_received
(
:puts
).
with
(
/git status/
)
expect
(
self
).
to
have_received
(
:puts
).
with
(
/git help/
)
expect
(
self
).
to
have_received
(
:warn
).
with
(
/git status/
)
expect
(
self
).
to
have_received
(
:warn
).
with
(
/git help/
)
end
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
OUTPUT
end
it
'sorts by matching size'
do
expect
(
matching_ce_refs
).
to
eq
(
%w[v9 v9.x v9.12 v9.123]
)
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