UNCLASSIFIED

Commit c85056c9 authored by Joshua Eason's avatar Joshua Eason
Browse files

Merge branch 'add-access-level' into 'master'

add access level to allow merge

See merge request !18
parents 819a08ee 67aab8b6
Pipeline #249081 passed with stage
in 26 minutes and 15 seconds
......@@ -30,7 +30,7 @@ def __getBranches(url, token, id):
'page': page
}
response = requests.get(url, params = PARAMS, headers = HEADER)
for i in response.json():
branches.append(i)
......@@ -63,7 +63,7 @@ def __getProtectedBranches(url, token, id):
'page': page
}
response = requests.get(url, params = PARAMS, headers = HEADER)
for i in response.json():
branches.append(i)
......@@ -123,6 +123,8 @@ def __createProtectedBranch(url, token, id, access):
if i != None:
PARAMS['allowed_to_merge[][user_id]'].append(i)
if 'merge_access_level' in access.keys():
PARAMS['merge_access_level'] = access['merge_access_level']
# Delete the protected branch first, otherwise this will fail. However, we don't know for sure
# that this is protected so we ignore the response
......@@ -144,7 +146,7 @@ def __listEqual(a, b):
if match == False:
return False
return True
##### Check methods
......@@ -175,7 +177,7 @@ def checkMissing(tbranches, branches):
for b in branches:
if a['name'] == b['name']:
found = True
if found == False:
notFound.append(a)
......@@ -202,7 +204,7 @@ def checkProtected(tprotected, protected):
# if len(a['allowed_to_push']) > 0 and len(b['allowed_to_push']) > 0:
# if __listEqual(a['allowed_to_push'], b['allowed_to_push']) == False:
# misprotectedBranches.append(a)
# if len(a['allowed_to_merge']) > 0 and len(b['allowed_to_merge']) > 0:
# if __listEqual(a['allowed_to_merge'], b['allowed_to_merge']) == False:
# misprotectedBranches.append(a)
......@@ -217,7 +219,7 @@ def checkProtected(tprotected, protected):
# misprotectedBranches.append(a)
if a['code_owner_approval_required'] != b['code_owner_approval_required']:
misprotectedBranches.append(a)
if found == False:
misprotectedBranches.append(a)
......@@ -231,7 +233,7 @@ def checkProtected(tprotected, protected):
##### Fix methods
def fix(url, token, tid, pid):
fixes = check(url, token, tid, pid)
if len(fixes['missing']) > 0:
fixMissing(url, token, pid, fixes['missing'])
......@@ -260,7 +262,10 @@ def fixProtected(url, token, id, misprotected):
if len(i['merge_access_levels']) > 0:
access['allowed_to_merge'] = []
for level in i['merge_access_levels']:
access['allowed_to_merge'].append(level['user_id'])
if level['user_id'] is not None:
access['allowed_to_merge'].append(level['user_id'])
elif level['access_level'] is not None:
access['merge_access_level'] = level['access_level']
# access['allowed_to_merge'] = i['merge_access_levels']
if 'unprotect_access_levels' in i.keys():
......@@ -281,7 +286,7 @@ def fixProtected(url, token, id, misprotected):
if 'allowed_to_unprotect' in i.keys():
if len(i['allowed_to_unprotect'] > 0):
access['allowed_to_unprotect'] = i['allowed_to_unprotect']
__createProtectedBranch(
url,
token,
......@@ -289,4 +294,4 @@ def fixProtected(url, token, id, misprotected):
access
)
# [{'access_level': 40, 'access_level_description': 'Al Fontaine', 'user_id': 1243, 'group_id': None}, {'access_level': 40, 'access_level_description': 'Andy Maksymowicz', 'user_id': 1242, 'group_id': None}, {'access_level': 40, 'access_level_description': 'Hunter Stevens', 'user_id': 3801, 'group_id': None}, {'access_level': 40, 'access_level_description': 'thomas.shepherd', 'user_id': 2280, 'group_id': None}, {'access_level': 0, 'access_level_description': 'No one', 'user_id': None, 'group_id': None}, {'access_level': 40, 'access_level_description': 'Joshua Eason', 'user_id': 514, 'group_id': None}, {'access_level': 40, 'access_level_description': 'alexander.klepal', 'user_id': 2237, 'group_id': None}, {'access_level': 40, 'access_level_description': 'balexand', 'user_id': 2971, 'group_id': None}, {'access_level': 40, 'access_level_description': 'Jeffrey Weatherford', 'user_id': 3827, 'group_id': None}, {'access_level': 40, 'access_level_description': 'Chris Byrd', 'user_id': 7184, 'group_id': None}, {'access_level': 40, 'access_level_description': 'sean.melissari', 'user_id': 1880, 'group_id': None}, {'access_level': 40, 'access_level_description': 'kwami.delali', 'user_id': 2588, 'group_id': None}, {'access_level': 40, 'access_level_description': 'Michael Simmons', 'user_id': 2570, 'group_id': None}, {'access_level': 40, 'access_level_description': 'Olga Ojjeh', 'user_id': 5562, 'group_id': None}, {'access_level': 40, 'access_level_description': 'Fred Melendez', 'user_id': 1572, 'group_id': None}, {'access_level': 40, 'access_level_description': 'Kelley Trujillo', 'user_id': 5480, 'group_id': None}, {'access_level': 40, 'access_level_description': 'bhearn', 'user_id': 2620, 'group_id': None}, {'access_level': 40, 'access_level_description': 'Zachary Sanders', 'user_id': 5938, 'group_id': None}, {'access_level': 40, 'access_level_description': 'shen_vickie@bah.com', 'user_id': 2469, 'group_id': None}, {'access_level': 40, 'access_level_description': 'Christopher Vernooy', 'user_id': 2242, 'group_id': None}]
\ No newline at end of file
# [{'access_level': 40, 'access_level_description': 'Al Fontaine', 'user_id': 1243, 'group_id': None}, {'access_level': 40, 'access_level_description': 'Andy Maksymowicz', 'user_id': 1242, 'group_id': None}, {'access_level': 40, 'access_level_description': 'Hunter Stevens', 'user_id': 3801, 'group_id': None}, {'access_level': 40, 'access_level_description': 'thomas.shepherd', 'user_id': 2280, 'group_id': None}, {'access_level': 0, 'access_level_description': 'No one', 'user_id': None, 'group_id': None}, {'access_level': 40, 'access_level_description': 'Joshua Eason', 'user_id': 514, 'group_id': None}, {'access_level': 40, 'access_level_description': 'alexander.klepal', 'user_id': 2237, 'group_id': None}, {'access_level': 40, 'access_level_description': 'balexand', 'user_id': 2971, 'group_id': None}, {'access_level': 40, 'access_level_description': 'Jeffrey Weatherford', 'user_id': 3827, 'group_id': None}, {'access_level': 40, 'access_level_description': 'Chris Byrd', 'user_id': 7184, 'group_id': None}, {'access_level': 40, 'access_level_description': 'sean.melissari', 'user_id': 1880, 'group_id': None}, {'access_level': 40, 'access_level_description': 'kwami.delali', 'user_id': 2588, 'group_id': None}, {'access_level': 40, 'access_level_description': 'Michael Simmons', 'user_id': 2570, 'group_id': None}, {'access_level': 40, 'access_level_description': 'Olga Ojjeh', 'user_id': 5562, 'group_id': None}, {'access_level': 40, 'access_level_description': 'Fred Melendez', 'user_id': 1572, 'group_id': None}, {'access_level': 40, 'access_level_description': 'Kelley Trujillo', 'user_id': 5480, 'group_id': None}, {'access_level': 40, 'access_level_description': 'bhearn', 'user_id': 2620, 'group_id': None}, {'access_level': 40, 'access_level_description': 'Zachary Sanders', 'user_id': 5938, 'group_id': None}, {'access_level': 40, 'access_level_description': 'shen_vickie@bah.com', 'user_id': 2469, 'group_id': None}, {'access_level': 40, 'access_level_description': 'Christopher Vernooy', 'user_id': 2242, 'group_id': None}]
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