Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
SA3
SA3LI Trial
Commits
00d67dbf
Commit
00d67dbf
authored
Apr 07, 2021
by
canterburym
Browse files
Working prototype merge test
parent
91ee2c5a
Pipeline
#3173
passed with stages
in 1 minute and 19 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
10 deletions
+11
-10
testing/merge_test.py
testing/merge_test.py
+11
-10
No files found.
testing/merge_test.py
View file @
00d67dbf
...
...
@@ -17,11 +17,11 @@ def gapi (query):
def
do
(
commandline
):
print
(
" Attempting: "
+
commandline
)
completedProc
=
subprocess
.
run
(
commandline
)
print
(
" STDOUT > "
+
"empty"
if
completedProc
.
stdout
is
None
else
completedProc
.
stdout
)
print
(
" STDERR > "
+
"empty"
if
completedProc
.
stderr
is
None
else
completedProc
.
stderr
)
completedProc
=
subprocess
.
run
(
commandline
,
capture_output
=
True
)
print
(
" STDOUT > "
+
(
"empty"
if
completedProc
.
stdout
is
None
else
completedProc
.
stdout
.
decode
(
'utf-8'
))
)
print
(
" STDERR > "
+
(
"empty"
if
completedProc
.
stderr
is
None
else
completedProc
.
stderr
.
decode
(
'utf-8'
))
)
print
(
f
" Completed with code
{
completedProc
.
returncode
}
"
)
return
completedProc
.
returncode
==
0
return
(
completedProc
.
returncode
==
0
,
completedProc
.
stdout
.
decode
(
'utf-8'
))
print
(
"Searching for corresponding MR..."
)
...
...
@@ -44,23 +44,24 @@ mrs = gapi(f"merge_requests?target_branch={mr['target_branch']}&state=opened")
mrs
=
[
m
for
m
in
mrs
if
m
[
'reference'
]
!=
mr
[
'reference'
]]
print
(
f
"
{
len
(
mrs
)
}
MRs found"
)
mergeConflicts
=
[]
mergeConflicts
=
{}
for
mr
in
mrs
:
source_branch
=
mr
[
'source_branch'
]
print
(
source_branch
)
try
:
do
(
f
"git fetch origin
{
source_branch
}
:
{
source_branch
}
"
)
if
not
do
(
f
"git merge --no-commit
{
source_branch
}
"
):
success
,
errStr
=
do
(
f
"git merge --no-commit
{
source_branch
}
"
)
if
not
success
:
print
(
"Merge NOT OK"
)
mergeConflicts
.
append
(
source_branch
)
mergeConflicts
[
source_branch
]
=
errStr
else
:
print
(
"Merge OK"
)
except
:
mergeConflicts
.
append
(
source_branch
)
except
Exception
as
ex
:
mergeConflicts
[
source_branch
]
=
str
(
ex
)
raise
finally
:
do
(
"git merge --abort"
)
print
(
f
"Merge conflicts with following branches:
{
mergeConflicts
}
"
)
exit
(
len
(
mergeConflicts
))
\ No newline at end of file
exit
(
len
(
mergeConflicts
.
keys
()))
\ No newline at end of file
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