Skip to content

Commit

Permalink
Merge pull request #1424 from DjLegolas/remove-opts-from-list
Browse files Browse the repository at this point in the history
Remove buggy functionality from list command
  • Loading branch information
danyeaw authored Aug 31, 2024
2 parents 740be54 + bdec143 commit 9a8b8b7
Showing 1 changed file with 1 addition and 75 deletions.
76 changes: 1 addition & 75 deletions gvsbuild/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,50 +14,13 @@
# along with this program; if not, see <http://www.gnu.org/licenses/>.

import json
import sys
from typing import List

import typer
from packaging import version

from gvsbuild.utils.base_project import Project, ProjectType


def set_projects_latest_versions(projects):
try:
import lastversion
except ImportError:
print("Please pip install lastversion in your Python environment")
sys.exit(1)

projects = {
project.name: project
for project in Project.list_projects()
if project.type.value in [ProjectType.PROJECT, ProjectType.TOOL]
and not project.internal
}

try:
for project in projects.values():
if project.internal:
continue
project.latest_version = lastversion.latest(
repo=project.repository or project.name,
major=project.lastversion_major,
)
if project.latest_version:
project.outdated = version.parse(
str(project.latest_version)
) > version.parse(project.version)

except lastversion.exceptions.ApiCredentialsError:
print(
"Create or update the GITHUB token at https://github.com/settings/tokens, then set or update the token "
"environmental variable with:\n$env:GITHUB_API_TOKEN=xxxxxxxxxxxxxxx"
)
exit(1)


def list_(
projects_names: List[str] = typer.Argument(None, help="The projects to list"),
project_type: ProjectType = typer.Option(
Expand All @@ -78,18 +41,6 @@ def list_(
help="Show list in JSON format",
rich_help_panel="Formatting Options",
),
latest: bool = typer.Option(
False,
"--latest",
help="Fetch latest information",
rich_help_panel="Formatting Options",
),
outdated: bool = typer.Option(
False,
"--outdated",
help="Only show outdated projects",
rich_help_panel="Selection Options",
),
):
Project.add_all()

Expand All @@ -103,19 +54,6 @@ def list_(
project for project in projects if project.type.value == project_type
]

if outdated:
latest = True

if latest:
set_projects_latest_versions(projects)

if outdated:
projects = [
project
for project in projects
if hasattr(project, "outdated") and project.outdated
]

if json_:

def _get_project_data(project):
Expand Down Expand Up @@ -145,16 +83,4 @@ def _get_project_data(project):
"name": f"{project.name:<{Project.name_len}}",
"version": f"{project.version:<45}",
}
if latest:
if (
hasattr(project, "latest_version")
and project.latest_version
):
params["latest_version"] = (
f"{str(project.latest_version):<45}"
)
else:
params["latest_version"] = "undefined"
print("\t{name} {version} {latest_version}".format(**params))
else:
print("\t{name} {version}".format(**params))
print("\t{name} {version}".format(**params))

0 comments on commit 9a8b8b7

Please sign in to comment.