Commit 86310af6 authored by canterburym's avatar canterburym
Browse files

Updated merge test

parent 37e1a010
......@@ -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", "")
......@@ -14,6 +15,13 @@ def gapi (query):
r = requests.get(url)
return json.loads(r.text)
def do (commandline):
print (" Attempting: " + commandline)
completedProc =
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)
do(f"git fetch origin {source_branch}:{source_branch}")
if not do(f"git merge --no-commit {source_branch}"):
print ("Merge NOT OK")
print ("Merge OK")
do("git merge --abort")
print (f"Merge conflicts with following branches: {mergeConflicts}")
\ 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