ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gitlab_helpers.py
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file gitlab_helpers.py
1 #! /usr/bin/env python
2 import requests
3 
4 def test_response(response):
5  response.raise_for_status()
6 
7 def get_project_id(url,project_name,token):
8  r = requests.get(url + "projects",headers={"PRIVATE-TOKEN":token})
10  proj_list = r.json()
11  matches = [proj_dict for proj_dict in proj_list if proj_dict["path_with_namespace"] == project_name]
12  if len(matches) > 1:
13  print "more than one project found matching the given project path"
14  print "going to use the first one"
15  return matches[0]["id"]
16 
17 def get_merge_request_id(url,project_name,token,project_id,mr_iid):
18  r = requests.get(url + "projects/{0}/merge_requests".format(project_id),headers={"PRIVATE-TOKEN":token})
19  test_response(r)
20  mr_list = r.json()
21  matches = [mr_dict for mr_dict in mr_list if mr_dict["iid"] == mr_iid]
22  if len(matches) > 1:
23  print "more than one merge request found matching the given project path and merge request IID"
24  print "going to use the first one"
25  return matches[0]["id"]
26