From 0da4429cce0a02ef400205a93c8b54cdcf6a9048 Mon Sep 17 00:00:00 2001 From: ganeshhubale Date: Wed, 29 Aug 2018 01:03:48 +0530 Subject: [PATCH 1/2] List all open PRs made by particular user to particular repo. on GitHub Signed-off-by: ganeshhubale --- plugins/github.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/github.py b/plugins/github.py index 8b2078e..1ad05be 100644 --- a/plugins/github.py +++ b/plugins/github.py @@ -7,9 +7,10 @@ def get_pull_requests(username,repository): github_url = "https://api.github.com" - r = requests.get(os.path.join(github_url, "repos", username, repository, "pulls")) + r = requests.get(os.path.join(github_url, "repos", repository, "pulls")) js = json.loads(r.content) for i in range(0, len(js)): - if 'title' in js[i].keys(): - list_of_pull_requests.append(js[i]['title']) + if username == js[i]['user']['login']: + if 'title' in js[i].keys(): + list_of_pull_requests.append(js[i]['title']) return list_of_pull_requests From ecb5139616f954c56d0aa5563f5e59b36ce21bf3 Mon Sep 17 00:00:00 2001 From: ganeshhubale Date: Wed, 29 Aug 2018 01:13:47 +0530 Subject: [PATCH 2/2] Plugin for GitHub Signed-off-by: ganeshhubale --- plugins/github.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/plugins/github.py b/plugins/github.py index 1ad05be..a6b6acf 100644 --- a/plugins/github.py +++ b/plugins/github.py @@ -3,14 +3,16 @@ import os -list_of_pull_requests=[] +list_of_pull_requests = [] + + +def get_pull_requests(username, repository): -def get_pull_requests(username,repository): github_url = "https://api.github.com" r = requests.get(os.path.join(github_url, "repos", repository, "pulls")) js = json.loads(r.content) - for i in range(0, len(js)): - if username == js[i]['user']['login']: - if 'title' in js[i].keys(): - list_of_pull_requests.append(js[i]['title']) + for pull in js: + if username == pull['user']['login']: + if 'title' in pull.keys(): + list_of_pull_requests.append(pull['title']) return list_of_pull_requests