diff --git a/scripts/pkg_in_pipe/pkg_in_pipe.py b/scripts/pkg_in_pipe/pkg_in_pipe.py index 148544fd..9e08aaaa 100755 --- a/scripts/pkg_in_pipe/pkg_in_pipe.py +++ b/scripts/pkg_in_pipe/pkg_in_pipe.py @@ -222,7 +222,7 @@ def find_commits(gh, repo, start_sha, end_sha) -> list[Commit]: A commit older that the end_sha commit and added by a merge commit won't appear in this list. """ cache_key = f'commits-2-{start_sha}-{end_sha}' - if cache_key in CACHE: + if not args.re_cache and cache_key in CACHE: return cast(list[Commit], CACHE[cache_key]) commits = [] if gh: @@ -238,7 +238,7 @@ def find_pull_requests(gh, repo, start_sha, end_sha): prs = set() for commit in find_commits(gh, repo, start_sha, end_sha): cache_key = f'commit-prs-3-{commit.sha}' - if cache_key in CACHE: + if not args.re_cache and cache_key in CACHE: prs.update(cast(list[PullRequest], CACHE[cache_key])) elif gh: commit_prs = list(commit.get_pulls()) @@ -268,11 +268,21 @@ def find_pull_requests(gh, repo, start_sha, end_sha): '--github-token', help="The token used to access the Github api", default=os.environ.get('GITHUB_TOKEN') ) parser.add_argument('--cache', help="The cache path", default="/tmp/pkg_in_pipe.cache") +parser.add_argument( + '--tag', '-t', dest='tags', help="The koji tags to include in the report", action='append', default=[] +) +parser.add_argument( + '--package', '-p', dest='packages', help="The packages to include in the report", action='append', default=[] +) +parser.add_argument('--re-cache', help="Refresh the cache", action='store_true') args = parser.parse_args() CACHE = diskcache.Cache(args.cache) RETENTION_TIME = 24 * 60 * 60 # 24 hours +DEFAULT_TAGS = [f'v{v}-{p}' for v in ['8.2', '8.3'] for p in ['incoming', 'ci', 'testing', 'candidates', 'lab']] +tags = args.tags or DEFAULT_TAGS + # load the issues from plane, so we can search for the plane card related to a build try: resp = requests.get( @@ -304,7 +314,6 @@ def find_pull_requests(gh, repo, start_sha, end_sha): print_plane_warning(out) if not gh: print_github_warning(out) - tags = [f'v{v}-{p}' for v in ['8.2', '8.3'] for p in ['incoming', 'ci', 'testing', 'candidates', 'lab']] with io.StringIO() as temp_out: try: # open koji session @@ -313,7 +322,9 @@ def find_pull_requests(gh, repo, start_sha, end_sha): session.ssl_login(config['cert'], None, config['serverca']) for tag in tags: print_table_header(temp_out, tag) - for tagged in sorted(session.listTagged(tag), key=lambda build: int(build['build_id']), reverse=True): + taggeds = sorted(session.listTagged(tag), key=lambda build: int(build['build_id']), reverse=True) + taggeds = [t for t in taggeds if t['package_name'] in args.packages or args.packages == []] + for tagged in taggeds: build = session.getBuild(tagged['build_id']) prs: list[PullRequest] = [] maintained_by = None