-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
""" | ||
Sync GitHub metadata repo across all projects. | ||
Metadata includes description, homepage (RTD docs if available) and topics. | ||
""" | ||
|
||
import autocommand | ||
|
||
from . import filters | ||
from . import git | ||
from . import github | ||
from . import repo | ||
from . import rtd | ||
|
||
|
||
@autocommand.autocommand(__name__) | ||
def main( | ||
keyword: filters.Keyword = None, # type: ignore | ||
tag: filters.Tag = None, # type: ignore | ||
): | ||
for project in filter(tag, filter(keyword, git.projects())): | ||
with git.temp_checkout(project, depth=1): | ||
md = repo.get_project_metadata() | ||
gh = github.Repo.from_project(project) | ||
gh_metadata = gh.get_metadata() | ||
# https://github.com/jaraco/pytest-perf/issues/10#issuecomment-1913669951 | ||
# homepage = md.homepage | ||
homepage = ( | ||
gh_metadata.get('homepage') | ||
or (project.rtd_url if rtd.rtd_exists(project) else None) | ||
) | ||
description = gh_metadata.get('description') or md.summary | ||
print(f'\n[Metadata for {gh}]') | ||
print('Homepage:', homepage) | ||
print('Description:', description) | ||
print('Topics:', ', '.join(project.topics)) | ||
gh.update_metadata( | ||
homepage=homepage, | ||
description=description, | ||
) | ||
print('\nUpdated metadata.') | ||
gh.add_topics(*project.topics) | ||
print('Added topics.\n') | ||
print(gh.url) |