|
42 | 42 | import subprocess
|
43 | 43 | import sys
|
44 | 44 | import tempfile
|
| 45 | +from typing import Iterable |
45 | 46 |
|
46 |
| -import click # pip install Click |
47 |
| -from git import Repo # pip install GitPython |
48 |
| -from github import Github # pip install PyGithub |
49 |
| -from jira import JIRA # pip install jira |
| 47 | +import click # pip install Click |
| 48 | +from git import Repo # pip install GitPython |
| 49 | +from github import Github # pip install PyGithub |
| 50 | +from jira import JIRA, resources # pip install jira |
50 | 51 | import oauthlib.oauth1
|
51 | 52 |
|
52 | 53 | if sys.version_info < (3, 0, 0):
|
@@ -454,21 +455,26 @@ def get_all_issues_for_version(auth_jira, release_version):
|
454 | 455 | .format(str(CXX_PROJ_ID), release_version)
|
455 | 456 | return auth_jira.search_issues(jql_query, maxResults=0)
|
456 | 457 |
|
457 |
| -def all_issues_closed(issues): |
| 458 | +def all_issues_closed(issues: Iterable[resources.Issue]) -> bool: |
458 | 459 | """
|
459 | 460 | Check to ensure that all issues are 'Closed'. Produce appropriate error
|
460 | 461 | message(s) and return False if any open issues are found.
|
461 | 462 | """
|
462 | 463 |
|
463 |
| - status_set = set(i.fields.status.name for i in issues) |
| 464 | + open_nonrelease_tickets = { |
| 465 | + iss |
| 466 | + for iss in issues |
| 467 | + # Don't include "release", as those are open until the release is done |
| 468 | + if "release" not in iss.fields.labels |
| 469 | + # Only include issues that are not marked as "closed" |
| 470 | + and iss.fields.status.name != "Closed" |
| 471 | + } |
464 | 472 |
|
465 |
| - if status_set.difference({'Closed'}): |
466 |
| - msg = 'Open tickets found. Cannot release!' |
467 |
| - msg += '\nThe following open tickets were found:' |
| 473 | + if open_nonrelease_tickets: |
| 474 | + msg = "Open tickets found. Cannot release!" |
| 475 | + msg += "\nThe following open tickets were found:" |
468 | 476 | click.echo(msg, err=True)
|
469 |
| - open_filter = lambda x: x.fields.status.name != 'Closed' |
470 |
| - open_issues = [i.key for i in filter(open_filter, issues)] |
471 |
| - click.echo('{}'.format(", ".join(open_issues)), err=True) |
| 477 | + click.echo("\n".join(f" - {iss.key}" for iss in open_nonrelease_tickets), err=True) |
472 | 478 | return False
|
473 | 479 |
|
474 | 480 | return True
|
|
0 commit comments