def main(): ANSIBULLBOT_VERSION = int(os.environ.get('ANSIBULLBOT_VERSION', 1)) ANSIBULLBOT_ALLOW_PRS = os.environ.get('ANSIBULLBOT_ALLOW_PRS', False) print('VERSION: %s' % ANSIBULLBOT_VERSION) if ANSIBULLBOT_VERSION == 3: main3() sys.exit(0) parser = argparse.ArgumentParser(description="Triage various PR queues " "for Ansible. (NOTE: only " "useful if you have commit " "access to the repo in " "question.)") parser.add_argument("repo", type=str, choices=['core', 'extras', 'ansible'], help="Repo to be triaged") parser.add_argument("--gh-user", "-u", type=str, help="Github username or token of triager") parser.add_argument("--gh-pass", "-P", type=str, help="Github password of triager") parser.add_argument("--gh-token", "-T", type=str, help="Github token of triager") parser.add_argument("--dry-run", "-n", action="store_true", help="Do not apply any changes.") parser.add_argument("--only_prs", action="store_true", help="Triage pullrequests only") parser.add_argument("--only_issues", action="store_true", help="Triage issues only") parser.add_argument("--verbose", "-v", action="store_true", help="Verbose output") parser.add_argument("--force", "-f", action="store_true", help="Do not ask questions") parser.add_argument("--safe_force", action="store_true", help="Ask questions only if a precise match not made.") parser.add_argument("--debug", "-d", action="store_true", help="Debug output") parser.add_argument("--pause", "-p", action="store_true", help="Always pause between PRs") parser.add_argument("--pr", "--id", type=int, help="Triage only the specified pr|issue") parser.add_argument("--start-at", type=int, help="Start triage at the specified pr|issue") parser.add_argument("--no_since", action="store_true", help="Do not use the since keyword to fetch issues") args = parser.parse_args() if args.pr and args.start_at: print("Error: Mutually exclusive: --start-at and --pr", file=sys.stderr) sys.exit(1) if args.force and args.pause: print("Error: Mutually exclusive: --force and --pause", file=sys.stderr) sys.exit(1) if args.force and args.safe_force: print("Error: Mutually exclusive: --force and --safe_force", file=sys.stderr) sys.exit(1) if args.only_prs and args.only_issues: print("Error: Mutually exclusive: --only_issues and --only_prs", file=sys.stderr) sys.exit(1) # THIS IS TO FORCE THE OLD BEHAVIOR BY DEFAULT if not ANSIBULLBOT_VERSION == 2 and not ANSIBULLBOT_ALLOW_PRS: args.only_prs = True args.only_issues = False if args.only_prs or not args.only_issues: triage = None kwargs = dict( verbose=args.verbose, github_user=args.gh_user, github_pass=args.gh_pass, github_token=args.gh_token, github_repo=args.repo, pr_number=args.pr, start_at_pr=args.start_at, always_pause=args.pause, force=args.force, dry_run=args.dry_run, ) if ANSIBULLBOT_VERSION == 1: triage = TriagePullRequests(**kwargs) elif ANSIBULLBOT_VERSION == 2: kwargs['safe_force'] = args.safe_force kwargs['no_since'] = args.no_since kwargs['number'] = kwargs['pr_number'] kwargs.pop('pr_number', None) kwargs['start_at'] = kwargs['start_at_pr'] kwargs.pop('start_at_pr', None) if args.repo == 'ansible': triage = AnsibleAnsibleTriagePullRequests(**kwargs) else: print('Version 2 PR triage for %s repo not yet implemented' % args.repo) sys.exit(1) if not triage: print('No triager for %s version %s' % (args.repo, ANSIBULLBOT_VERSION)) sys.exit(1) triage.run() elif args.only_issues or not args.only_prs: kwargs = dict(verbose=args.verbose, github_user=args.gh_user, github_pass=args.gh_pass, github_token=args.gh_token, github_repo=args.repo, number=args.pr, start_at=args.start_at, always_pause=args.pause, force=args.force, safe_force=args.safe_force, dry_run=args.dry_run, no_since=args.no_since) if args.repo == 'ansible': triage = AnsibleAnsibleTriageIssues(**kwargs) else: triage = TriageIssues(**kwargs) triage.run()
def main(): parser = argparse.ArgumentParser(description="Triage various PR queues " "for Ansible. (NOTE: only " "useful if you have commit " "access to the repo in " "question.)") parser.add_argument("repo", type=str, choices=['core', 'extras'], help="Repo to be triaged") parser.add_argument("--gh-user", "-u", type=str, help="Github username or token of triager") parser.add_argument("--gh-pass", "-P", type=str, help="Github password of triager") parser.add_argument("--gh-token", "-T", type=str, help="Github token of triager") parser.add_argument("--dry-run", "-n", action="store_true", help="Do not apply any changes.") parser.add_argument("--only_prs", action="store_true", help="Triage pullrequests only") parser.add_argument("--only_issues", action="store_true", help="Triage issues only") parser.add_argument("--verbose", "-v", action="store_true", help="Verbose output") parser.add_argument("--force", "-f", action="store_true", help="Do not ask questions") parser.add_argument("--safe_force", action="store_true", help="Ask questions only if a precise match not made.") parser.add_argument("--debug", "-d", action="store_true", help="Debug output") parser.add_argument("--pause", "-p", action="store_true", help="Always pause between PRs") parser.add_argument("--pr", "--id", type=int, help="Triage only the specified pr|issue") parser.add_argument("--start-at", type=int, help="Start triage at the specified pr|issue") args = parser.parse_args() if args.pr and args.start_at: print("Error: Mutually exclusive: --start-at and --pr", file=sys.stderr) sys.exit(1) if args.force and args.pause: print("Error: Mutually exclusive: --force and --pause", file=sys.stderr) sys.exit(1) if args.force and args.safe_force: print("Error: Mutually exclusive: --force and --safe_force", file=sys.stderr) sys.exit(1) if args.only_prs and args.only_issues: print("Error: Mutually exclusive: --only_issues and --only_prs", file=sys.stderr) sys.exit(1) # THIS IS TO FORCE THE OLD BEHAVIOR BY DEFAULT ANSIBULLBOT_VERSION = int(os.environ.get('ANSIBULLBOT_VERSION', 1)) if not ANSIBULLBOT_VERSION == 2: args.only_prs = True args.only_issues = False if args.only_prs or not args.only_issues: triage = TriagePullRequests( verbose=args.verbose, github_user=args.gh_user, github_pass=args.gh_pass, github_token=args.gh_token, github_repo=args.repo, pr_number=args.pr, start_at_pr=args.start_at, always_pause=args.pause, force=args.force, dry_run=args.dry_run, ) triage.run() elif args.only_issues or not args.only_prs: triage = TriageIssues( verbose=args.verbose, github_user=args.gh_user, github_pass=args.gh_pass, github_token=args.gh_token, github_repo=args.repo, number=args.pr, start_at=args.start_at, always_pause=args.pause, force=args.force, safe_force=args.safe_force, dry_run=args.dry_run, ) triage.run()