Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Greasy Fork should take precedence #3

Merged
merged 1 commit into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ Every project can also be expanded to show additional project information (by cl
</tr>
<tr>
<td><code>greasy_fork_id</code></td>
<td>Greasy Fork ID of the project. This is the number in script's URL, e.g. <code>299792458</code> for <code>https://greasyfork.org/scripts/299792458-speed-of-light</code>.</td>
<td>Greasy Fork ID of the project. This is the number in script's URL, e.g. <code>299792458</code> for <code>https://greasyfork.org/scripts/299792458-speed-of-light</code>. If set, homepage and description on Greasy Fork will take precedence over those on GitHub.</td>
</tr>
</table>

Expand Down
14 changes: 9 additions & 5 deletions src/best_of/integrations/greasy_fork_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,17 @@ def update_project_info(self, project_info: Dict) -> None:
)
return

if not project_info.homepage:
# Greasy Fork takes precedence over GitHub.
# A GitHub repository may contain multiple scripts on Greasy Fork,
# therefore Greasy Fork gives more specific metadata.
if (
not project_info.homepage
or project_info.homepage == project_info.github_url
):
project_info.homepage = greasy_fork_info.url

if (
not project_info.description
or len(project_info.description) < MIN_PROJECT_DESC_LENGTH
) and greasy_fork_info.description:
# Greasy Fork takes precedence for the same reason.
if greasy_fork_info.description:
project_info.description = greasy_fork_info.description

if not project_info.license:
Expand Down