Skip to content

Commit

Permalink
fix: skip a not useful commit msg
Browse files Browse the repository at this point in the history
  • Loading branch information
kowyo authored Oct 24, 2024
1 parent 945e265 commit 396f777
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions scripts/gen_repo_update_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,33 @@ def get_http_session():
session.mount('https://', adapter)
return session


# Function to get the latest commit
def get_latest_commit(owner, repo):
commits_url = f'https://api.github.com/repos/{owner}/{repo}/commits'
params = {'since': '2000-01-01T00:00:01Z',
'per_page': 1}
response = session.get(commits_url, headers=headers, params=params)
'per_page': 10} # Fetch more than one commit
response = requests.get(commits_url, headers=headers, params=params)
commit_info = dict()

if response.status_code == 200:
commit = response.json()
commit_info['author'] = commit[0]['commit']['author']['name']
commit_info['date'] = datetime.datetime.strptime(commit[0]['commit']['author']['date'],
"%Y-%m-%dT%H:%M:%SZ") + datetime.timedelta(hours=8) # UTC-8
commit_info['message'] = commit[0]['commit']['message']
commits = response.json()

for commit in commits:
message = commit['commit']['message']
# Skip commits with messages starting with "Replace"
if message.startswith("Replace"):
continue

# If the commit does not start with "Replace", process it
commit_info['author'] = commit['commit']['author']['name']
commit_info['date'] = datetime.datetime.strptime(commit['commit']['author']['date'],
"%Y-%m-%dT%H:%M:%SZ") + datetime.timedelta(hours=8) # UTC-8
commit_info['message'] = message
return commit_info # Return the first valid commit

else:
print(f'Failed to fetch commits for {repo}: {response.status_code}')
return commit_info

return commit_info # Return empty if no valid commit was found


def save_latest_update(commit_info):
Expand Down

0 comments on commit 396f777

Please sign in to comment.