Skip to content

Commit 06a3e94

Browse files
committed
Print pulls in CI info comment block
Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
1 parent c401c6f commit 06a3e94

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

ros_github_scripts/ci_for_pr.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ def prompt_pull_selection(
136136
Return the list of chosen PRs.
137137
"""
138138
choices: Dict[int, github.Issue.Issue] = {}
139+
texts = []
139140
while True:
140141
print('\n>>> Choose a PR to add to Gist <<<\n')
141142
for i, option in enumerate(pulls):
@@ -157,11 +158,13 @@ def prompt_pull_selection(
157158

158159
try:
159160
choice_index = int(choice)
160-
choices[choice_index] = pulls[choice_index]
161+
current_choice = pulls[choice_index]
162+
texts.append(print_format_issue(current_choice))
163+
choices[choice_index] = current_choice
161164
except (ValueError, IndexError):
162165
print('{} is not a valid choice'.format(choice))
163166

164-
return [issue.as_pull_request() for issue in choices.values()]
167+
return (texts, [issue.as_pull_request() for issue in choices.values()])
165168

166169

167170
def validate_and_fetch_pull_list(
@@ -192,9 +195,15 @@ def validate_and_fetch_pull_list(
192195

193196

194197
def format_ci_details(
195-
gist_url: str, extra_build_args: str, extra_test_args: str, target_release: str,
198+
gist_url: str,
199+
extra_build_args: str,
200+
extra_test_args: str,
201+
target_release: str,
202+
target_pulls: List[str],
196203
) -> str:
204+
pull_text = ', '.join(target_pulls)
197205
return '\n'.join([
206+
f'Pulls: {pull_text}',
198207
f'Gist: {gist_url}',
199208
f'BUILD args: {extra_build_args}',
200209
f'TEST args: {extra_test_args}',
@@ -337,15 +346,16 @@ def parse_args():
337346
def main():
338347
github_access_token = os.environ.get('GITHUB_ACCESS_TOKEN')
339348
if not github_access_token:
340-
github_access_token = os.environ.get('GITHUB_TOKEN')
349+
github_access_token = os.environ.get('GITHUB_TOKEN')
341350
if not github_access_token:
342351
panic('Neither environment variable GITHUB_ACCESS_TOKEN nor GITHUB_TOKEN are set')
343352
github_instance = Github(github_access_token)
344353

345354
parsed = parse_args()
355+
pull_texts = parsed.pulls
346356
if parsed.interactive:
347357
all_user_pulls = fetch_user_pulls(github_instance)
348-
chosen_pulls = prompt_pull_selection(all_user_pulls)
358+
pull_texts, chosen_pulls = prompt_pull_selection(all_user_pulls)
349359
elif not parsed.pulls:
350360
panic('You must either choose --interactive or provide --pulls')
351361
else:
@@ -370,7 +380,8 @@ def main():
370380

371381
comment_texts = []
372382
comment_texts.append(
373-
format_ci_details(gist_url, extra_build_args, extra_test_args, parsed.target))
383+
format_ci_details(
384+
gist_url, extra_build_args, extra_test_args, parsed.target, pull_texts))
374385
if parsed.build:
375386
user = github_instance.get_user().login
376387
comment_texts.append(

0 commit comments

Comments
 (0)