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
86310af6
Commit
86310af6
authored
Apr 07, 2021
by
canterburym
Browse files
Updated merge test
parent
37e1a010
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
1 deletion
+30
-1
testing/merge_test.py
testing/merge_test.py
+30
-1
No files found.
testing/merge_test.py
View file @
86310af6
...
...
@@ -2,8 +2,9 @@ import os
import
pprint
import
requests
import
json
import
subprocess
print
(
"Hello world"
)
print
(
"Hello world
v1.1
"
)
crCommitBranch
=
os
.
environ
.
get
(
"CI_COMMIT_REF_NAME"
,
"cr/TS33128/0163"
)
apiUrl
=
os
.
environ
.
get
(
"CI_API_V4_URL"
,
"https://forge.3gpp.org/rep/api/v4"
)
...
...
@@ -14,6 +15,13 @@ def gapi (query):
r
=
requests
.
get
(
url
)
return
json
.
loads
(
r
.
text
)
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
)
print
(
f
" Completed with code
{
completedProc
.
returncode
}
"
)
return
completedProc
.
returncode
==
0
print
(
"Searching for corresponding MR..."
)
...
...
@@ -33,5 +41,26 @@ print (f"Target branch is {mr['target_branch']}")
print
(
"Searching for open MRs targeting same branch..."
)
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
=
[]
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
}
"
):
print
(
"Merge NOT OK"
)
mergeConflicts
.
append
(
source_branch
)
else
:
print
(
"Merge OK"
)
except
:
mergeConflicts
.
append
(
source_branch
)
raise
finally
:
do
(
"git merge --abort"
)
print
(
f
"Merge conflicts with following branches:
{
mergeConflicts
}
"
)
exit
(
len
(
mergeConflicts
))
\ 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