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
16872448
Commit
16872448
authored
Jul 02, 2018
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reorder methods so it's easier to read
parent
18696a0d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
50 deletions
+49
-50
scripts/ee_specific_check/ee_specific_check.rb
scripts/ee_specific_check/ee_specific_check.rb
+49
-50
No files found.
scripts/ee_specific_check/ee_specific_check.rb
View file @
16872448
...
@@ -21,7 +21,6 @@ module EESpecificCheck
...
@@ -21,7 +21,6 @@ module EESpecificCheck
def
git_version
def
git_version
say
run_git_command
(
'--version'
)
say
run_git_command
(
'--version'
)
say
run_git_command
(
'mergetool'
)
end
end
def
say
(
message
)
def
say
(
message
)
...
@@ -62,6 +61,55 @@ module EESpecificCheck
...
@@ -62,6 +61,55 @@ module EESpecificCheck
"
#{
remote_to_fetch
}
/
#{
branch_to_fetch
}
"
"
#{
remote_to_fetch
}
/
#{
branch_to_fetch
}
"
end
end
def
find_ce_compare_head
(
ce_fetch_head
,
ce_fetch_base
,
ce_merge_base
)
if
git_ancestor?
(
ce_merge_base
,
ce_fetch_base
)
# CE ahead of EE
find_backward_ce_head
(
ce_fetch_head
,
ce_fetch_base
,
ce_merge_base
)
else
# EE ahead of CE
find_forward_ce_head
(
ce_merge_base
,
ce_fetch_head
)
end
end
def
git_ancestor?
(
ancestor
,
descendant
)
run_git_command
(
"merge-base --is-ancestor
#{
ancestor
}
#{
descendant
}
&& echo y"
)
==
'y'
end
def
find_backward_ce_head
(
ce_fetch_head
,
ce_fetch_base
,
ce_merge_base
)
if
ce_fetch_head
.
start_with?
(
'canonical-ce'
)
||
# No specific CE branch
ce_fetch_base
==
ce_merge_base
# Up-to-date, no rebase needed
ce_merge_base
else
# Rebase CE to remove commits in CE haven't merged into EE
checkout_and_rebase
(
ce_merge_base
,
ce_fetch_base
,
ce_fetch_head
)
end
end
def
find_forward_ce_head
(
ce_merge_base
,
ce_fetch_head
)
with_detached_head
(
ce_fetch_head
)
do
run_git_command
(
"merge
#{
ce_merge_base
}
-s recursive -X patience"
)
status
=
git_status
if
status
.
porcelain
==
''
status
.
head
else
run_git_command
(
"merge --abort"
)
say
<<~
MESSAGE
💥 Git status not clean! This means there's a conflict in
💥
#{
ce_fetch_head
}
with canonical-ce/master. Please resolve
💥 the conflict from CE master and retry this job.
⚠️ Git status:
#{
status
.
porcelain
}
MESSAGE
exit
(
254
)
end
end
end
# We rebase onto the commit which is the latest commit presented in both
# We rebase onto the commit which is the latest commit presented in both
# CE and EE, i.e. ce_merge_base, cutting off commits aren't merged into
# CE and EE, i.e. ce_merge_base, cutting off commits aren't merged into
# EE yet. Here's an example:
# EE yet. Here's an example:
...
@@ -176,11 +224,6 @@ module EESpecificCheck
...
@@ -176,11 +224,6 @@ module EESpecificCheck
run_git_command
(
'clean -fd'
)
if
ENV
[
'CI'
]
run_git_command
(
'clean -fd'
)
if
ENV
[
'CI'
]
end
end
def
git_ancestor?
(
ancestor
,
descendant
)
run_git_command
(
"merge-base --is-ancestor
#{
ancestor
}
#{
descendant
}
&& echo y"
)
==
'y'
end
def
remove_remotes
def
remove_remotes
run_git_command
(
run_git_command
(
"remote remove canonical-ee"
,
"remote remove canonical-ee"
,
...
@@ -212,50 +255,6 @@ module EESpecificCheck
...
@@ -212,50 +255,6 @@ module EESpecificCheck
end
end
end
end
def
find_ce_compare_head
(
ce_fetch_head
,
ce_fetch_base
,
ce_merge_base
)
if
git_ancestor?
(
ce_merge_base
,
ce_fetch_base
)
# CE ahead of EE
find_backward_ce_head
(
ce_fetch_head
,
ce_fetch_base
,
ce_merge_base
)
else
# EE ahead of CE
find_forward_ce_head
(
ce_merge_base
,
ce_fetch_head
)
end
end
def
find_backward_ce_head
(
ce_fetch_head
,
ce_fetch_base
,
ce_merge_base
)
if
ce_fetch_head
.
start_with?
(
'canonical-ce'
)
||
# No specific CE branch
ce_fetch_base
==
ce_merge_base
# Up-to-date, no rebase needed
ce_merge_base
else
# Rebase CE to remove commits in CE haven't merged into EE
checkout_and_rebase
(
ce_merge_base
,
ce_fetch_base
,
ce_fetch_head
)
end
end
def
find_forward_ce_head
(
ce_merge_base
,
ce_fetch_head
)
with_detached_head
(
ce_fetch_head
)
do
run_git_command
(
"merge
#{
ce_merge_base
}
-s recursive -X patience"
)
status
=
git_status
if
status
.
porcelain
==
''
status
.
head
else
run_git_command
(
"merge --abort"
)
say
<<~
MESSAGE
💥 Git status not clean! This means there's a conflict in
💥
#{
ce_fetch_head
}
with canonical-ce/master. Please resolve
💥 the conflict from CE master and retry this job.
⚠️ Git status:
#{
status
.
porcelain
}
MESSAGE
exit
(
254
)
end
end
end
def
ce_repo_url
def
ce_repo_url
@ce_repo_url
||=
ENV
.
fetch
(
'CI_REPOSITORY_URL'
,
'https://gitlab.com/gitlab-org/gitlab-ce.git'
).
sub
(
'gitlab-ee'
,
'gitlab-ce'
)
@ce_repo_url
||=
ENV
.
fetch
(
'CI_REPOSITORY_URL'
,
'https://gitlab.com/gitlab-org/gitlab-ce.git'
).
sub
(
'gitlab-ee'
,
'gitlab-ce'
)
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