Skip to content

Commit

Permalink
refactor: Greasy Fork should take precedence
Browse files Browse the repository at this point in the history
  • Loading branch information
YDX-2147483647 committed Mar 4, 2024
1 parent 72fe162 commit 950ae89
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
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

0 comments on commit 950ae89

Please sign in to comment.