Skip to content

Commit

Permalink
clean pkg name
Browse files Browse the repository at this point in the history
  • Loading branch information
Chizkiyahu committed Oct 31, 2023
1 parent 3ae4fba commit 5219f93
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ jobs:
token: ${{ secrets.PAT_TOKEN }}
repository_owner: ${{ github.repository_owner }}
repository: ${{ github.repository }}
package_name: p1
package_name: ${{ github.repository }}/p1
untagged_only: false
owner_type: user

Expand Down
8 changes: 7 additions & 1 deletion clean_ghcr.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import subprocess
import urllib.parse

import requests
import argparse
Expand Down Expand Up @@ -55,8 +56,9 @@ def get_req(path, params=None):

def get_list_packages(owner, repo_name, owner_type, package_name):
if package_name:
clean_package_name = urllib.parse.quote(package_name, safe='')
url = get_url(
f"/{owner_type}s/{owner}/packages/container/{package_name}")
f"/{owner_type}s/{owner}/packages/container/{clean_package_name}")
response = requests.get(url, headers=get_base_headers())
if not response.ok:
if response.status_code == 404:
Expand Down Expand Up @@ -221,6 +223,10 @@ def get_args():
f"Mismatch in repository:{args.repository} and repository_owner:{args.repository_owner}"
)
args.repository = repository
if args.package_name and args.package_name.count("/") == 2:
_, repo_name, package_name = args.package_name.split("/")
package_name = f"{repo_name}/{package_name}"
args.package_name = package_name
args.repository = args.repository.lower()
args.repository_owner = args.repository_owner.lower()
args.package_name = args.package_name.lower()
Expand Down

0 comments on commit 5219f93

Please sign in to comment.