-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathchecker.py
More file actions
29 lines (25 loc) · 988 Bytes
/
Copy pathchecker.py
File metadata and controls
29 lines (25 loc) · 988 Bytes
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
import requests
import time
def check_for_new_commits(owner, repo, last_known_commit=None):
url = f"https://api.github.com/repos/{owner}/{repo}/commits"
response = requests.get(url)
if response.status_code == 200:
commits = response.json()
latest_commit_sha = commits[0]['sha']
print(commits)
if last_known_commit != latest_commit_sha:
print(f"Новый коммит обнаружен: {latest_commit_sha}")
return latest_commit_sha
else:
print("Новых коммитов нет")
return last_known_commit
else:
print(f"Ошибка при запросе: {response.status_code}")
return last_known_commit
# Пример использования
owner = "Shrekami"
repo = "Tkinter_tutorials"
last_commit = None
while True:
last_commit = check_for_new_commits(owner, repo, last_commit)
time.sleep(300) # Проверка каждые 5 минут