Skip to content

Commit

Permalink
close #90, close #89, close #88,
Browse files Browse the repository at this point in the history
close #87, close #86, close #85
  • Loading branch information
Patrick-DE committed May 24, 2023
1 parent 685333f commit 98a9ec8
Show file tree
Hide file tree
Showing 4 changed files with 5,411 additions and 4,524 deletions.
30 changes: 11 additions & 19 deletions merger/fetchAllLatestGitCommits.py → merger/fetchAllGitData.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
load_dotenv("..\.env")
GITHUB_API_KEY = os.getenv('GITHUB_API_KEY')

def getLatestCommit(url):
def getGitHubData(url):
match = re.search(r"github\.com/([^/]+)/([^/]+)", url)
if not match:
return None
Expand All @@ -30,37 +30,29 @@ def getLatestCommit(url):

# Extract the relevant information from the response
data = json.loads(response.text)
pushed_at = data["pushed_at"]
archived = data["archived"]
disabled = data["disabled"]
return data

# Return the information as a dictionary
return pushed_at

def fetchAllLatestGitCommits():
def fetchAllGitData():
with open('tools.json', 'r') as f:
toolBase: Tools = json.load(f)

for tool in toolBase:
if "github.com" in tool["source"]:
if "latest_commit" not in tool:
tool["latest_commit"] = None

#if tool["latest_commit"] == None:
try:
updated = getLatestCommit(tool["source"])
if updated == None:
continue

tool["latest_commit"] = updated
data = getGitHubData(tool["source"])
except Exception as ex:
#print(ex)
print(ex)
f = open("tools.json", "w")
json.dump(toolBase, f, indent=2)
f.close()

if data:
tool["latest_commit"] = data.get("pushed_at", None)
tool["language"] = data.get("language", None)


f = open("tools.json", "w")
json.dump(toolBase, f, indent=2)
f.close()

#fetchAllLatestGitCommits()
#fetchAllGitData()
4 changes: 2 additions & 2 deletions merger/merger.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import sys
import json
import os
from fetchAllLatestGitCommits import fetchAllLatestGitCommits
from fetchAllGitData import fetchAllGitData
from tools import ToolSchema
from techniques import TechniqueSchema
from jsonschema import validate
Expand Down Expand Up @@ -86,4 +86,4 @@
print ("close #" + str(iss["number"]),end=', ')

print("\n\nFetching latest commits for git sources...")
fetchAllLatestGitCommits()
fetchAllGitData()
3 changes: 2 additions & 1 deletion merger/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ def replace_oss(arr):
"content": {"type": "string"},
"commands": {"type": "array","items": {"type": "object"}},
"references": {"type": "array","items": {"type": "string"}},
"latest_commit": {"type": "string","format": "uri","qt-uri-protocols": ["http","https"]}
"latest_commit": {"type": "string","format": "uri","qt-uri-protocols": ["http","https"]},
"language": {"type": "string"}
},
"required": ["name", "phases", "category", "platforms", "source", "description"],
}
Loading

0 comments on commit 98a9ec8

Please sign in to comment.