Commit 00d67dbf authored by canterburym's avatar canterburym
Browse files

Working prototype merge test

parent 91ee2c5a
Pipeline #3173 passed with stages
in 1 minute and 19 seconds
......@@ -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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment