Skip to content

Commit

Permalink
add archived parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
yeoldegrove committed Oct 16, 2024
1 parent c0f77c4 commit 5b0bd00
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions glrd
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ def filter_active_releases(releases):
current_timestamp = get_current_timestamp()
return [release for release in releases if is_active_release(release, current_timestamp)]

def is_archived_release(release, current_timestamp):
"""Check if the release archived based on its EOL timestamp."""
eol_timestamp = release.get('lifecycle', {}).get('eol', {}).get('timestamp')
return eol_timestamp and eol_timestamp < current_timestamp

def filter_archived_releases(releases):
"""Filter and return only archived releases."""
current_timestamp = get_current_timestamp()
return [release for release in releases if is_archived_release(release, current_timestamp)]

def filter_releases(releases, release_types=None, version=None):
"""Filter releases by type and/or version."""
if version:
Expand Down Expand Up @@ -208,6 +218,7 @@ def parse_arguments():
parser.add_argument('--output-type', choices=['json', 'yaml', 'markdown', 'mermaid_gantt', 'shell'], default='shell', help="Output format: json, yaml, markdown, mermaid_gantt, shell (default).")
parser.add_argument('--output-description', type=str, default='Garden Linux Releases', help="Description, added to certain outputs, e.g. mermaid (default: 'Garden Linux Releases').")
parser.add_argument('--active', action='store_true', help="Show only active releases.")
parser.add_argument('--archived', action='store_true', help="Show only archived releases.")
parser.add_argument('--latest', action='store_true', help="Show the latest active major.minor release.")
parser.add_argument('--type', type=str, default='stable,patch', help="Filter by release types (comma-separated list, default: stable,patch). E.g., --type stable,patch,nightly,dev,next")
parser.add_argument('--version', type=str, help="Filter by a specific version (major or major.minor). E.g., --version 1312 or --version 1312.0")
Expand Down Expand Up @@ -272,6 +283,10 @@ def main():
if args.active:
releases = filter_active_releases(releases)

# Show only archived releases if specified
if args.archived:
releases = filter_archived_releases(releases)

# Sort releases by major and minor version
releases = sort_releases(releases)

Expand Down

0 comments on commit 5b0bd00

Please sign in to comment.