-
Notifications
You must be signed in to change notification settings - Fork 1
/
RepoFunctions.py
67 lines (41 loc) · 1.52 KB
/
RepoFunctions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import os
import requests
import json
import subprocess
import pandas as pd
def get_Releases(org, repo_name, latest=False):
#git_url = "https://api.github.com/repos/SymphoniaLauren/Tales-of-Rebirth/releases"
git_url = "https://api.github.com/repos/{}/{}/releases".format(org, repo_name)
if latest:
git_url = git_url+"/latest"
header = {
"Accept":"application/vnd.github.v3+json"
}
res = requests.get(git_url)
json_res = json.loads(res.text)
return json_res
def refresh_repo(repo_name):
base_path = os.path.join(os.getcwd(), "..", repo_name)
print("Repo to refresh: {}".format(base_path))
listFile = subprocess.run(
["git", "pull"],
cwd=base_path
)
def get_pull_requests(org, repo_name):
api_url = "https://api.github.com/repos/{}/{}/pulls?state=all".format(org, repo_name)
header = {
"Accept":"application/vnd.github.v3+json"
}
res = requests.get(api_url)
json_res = json.loads(res.text)
#Taking Top 5 PR
top5 = json_res[0:5]
return top5
def get_pull_requests_message(org, repo_name):
#Get Datas
top5_prs = get_pull_requests(org, repo_name)
message ='Here are the PRs recently : '
for pr in top5_prs:
message = message + "<br>"
message += '{} - {} by {} ... {}'.format(pr['created_at'], pr['title'], pr['user']['login'], pr['_links']['html']['href'])
return message