diff --git a/odoo_tools/cli/pending.py b/odoo_tools/cli/pending.py index 7f41142..9549045 100644 --- a/odoo_tools/cli/pending.py +++ b/odoo_tools/cli/pending.py @@ -21,8 +21,9 @@ def cli(): "-s", "--state", "state", - help="only list pull requests in the specified state (open, merged, closed)", -) # TODO list valid values + help="only list pull requests in the specified state", + type=click.Choice(["open", "merged", "closed"], case_sensitive=False), +) @click.option( "-p", "--purge", diff --git a/odoo_tools/utils/pending_merge.py b/odoo_tools/utils/pending_merge.py index 150939e..a48fa6b 100644 --- a/odoo_tools/utils/pending_merge.py +++ b/odoo_tools/utils/pending_merge.py @@ -407,8 +407,13 @@ def show_prs(self, state=None, purge=None): ui.echo(f"Merge file: {self.merges_path}") all_prs = aggregator.collect_prs_info() if state is not None: - # filter only our state - all_prs = {k: v for k, v in all_prs.items() if k == state} + if state == "merged": + all_prs = {"closed": all_prs.get("closed", [])} + all_prs["closed"] = [ + pr for pr in all_prs["closed"] if pr.get("merged") == "merged" + ] + else: + all_prs = {k: v for k, v in all_prs.items() if k == state} for pr_state, prs in all_prs.items(): ui.echo(f"State: {pr_state}") for i, pr_info in enumerate(prs, 1):