Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import json
- from requests import Response
- from typing import Dict, Any
- token = "token"
- url = "https://gitlab.com/api/v4/projects/1/merge_requests?state=opened&scope=all&per_page=1000&private_token=" + token
- response = requests.get(url) # type: Response
- merge_requests_by_author = {} # type: Dict[str, List[Tuple]]
- if response.status_code == 200:
- json_body = response.text
- request_body = json.loads(json_body) # type: List[Dict[Any, Any]]
- request_body
- def lookup(iid):
- url = "https://gitlab.com/api/v4/projects/1/merge_requests/{}/changes?private_token={}".format(iid, token)
- response = requests.get(url) # type: Response
- merge_requests_by_author = {} # type: Dict[str, List[Tuple]]
- if response.status_code == 200:
- json_body = response.text
- request_body = json.loads(json_body) # type: List[Dict[Any, Any]]
- return request_body
- def get_requests():
- url = "https://gitlab.com/api/v4/projects/1/merge_requests?state=opened&scope=all&per_page=1000&private_token=" + token
- response = requests.get(url) # type: Response
- merge_requests_by_author = {} # type: Dict[str, List[Tuple]]
- if response.status_code == 200:
- json_body = response.text
- request_body = json.loads(json_body) # type: List[Dict[Any, Any]]
- for merge_request in request_body:
- yield lookup(merge_request['iid'])
- for request in get_requests():
- paths = [change['old_path'] for change in request['changes']]
- if "my_refactored_file.py" in paths:
- print("my_refactored_file.py found:{}:{} - {}".format(request['iid'], request['title'], request['author']['name']))
Advertisement
Add Comment
Please, Sign In to add comment