2022-04-10 17:46:47 -04:00
|
|
|
import os
|
2022-04-10 17:37:01 -04:00
|
|
|
import requests
|
|
|
|
|
import json
|
2022-04-10 17:46:47 -04:00
|
|
|
import subprocess
|
2022-05-21 23:08:00 -04:00
|
|
|
import pandas as pd
|
2022-04-10 17:37:01 -04:00
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
2022-04-10 17:46:47 -04:00
|
|
|
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(
|
2022-04-11 19:02:03 -04:00
|
|
|
["git", "pull"],
|
2022-04-10 17:46:47 -04:00
|
|
|
cwd=base_path
|
|
|
|
|
)
|
2022-05-21 23:08:00 -04:00
|
|
|
|
|
|
|
|
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]
|
|
|
|
|
|
2022-05-21 23:20:56 -04:00
|
|
|
return top5
|
2022-05-21 23:08:00 -04:00
|
|
|
|
2022-05-21 23:12:01 -04:00
|
|
|
def get_pull_requests_message(org, repo_name):
|
|
|
|
|
|
|
|
|
|
#Get Datas
|
2022-05-21 23:20:56 -04:00
|
|
|
top5_prs = get_pull_requests(org, repo_name)
|
|
|
|
|
|
|
|
|
|
message ='Here are the PRs recently : '
|
|
|
|
|
|
|
|
|
|
for pr in top5_prs:
|
|
|
|
|
|
2022-05-21 23:25:45 -04:00
|
|
|
message = message + "<br>"
|
2022-05-21 23:30:52 -04:00
|
|
|
message += '{} - {} by {} ... {}'.format(pr['created_at'], pr['title'], pr['user']['login'], pr['_links']['html']['href'])
|
2022-05-21 23:20:56 -04:00
|
|
|
|
|
|
|
|
return message
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-05-21 23:12:01 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|