Skip to content

Commit e706400

Browse files
committed
Put verbose output in PR description.
1 parent fee9f22 commit e706400

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

scripts/submodule_updater.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,14 @@ def load_remote(repo, remote, config_tokens):
110110
if submodule.module_exists():
111111
submodules.append(submodule)
112112

113+
pr_body_text = "Updates application submodules:\n"
114+
113115
submodule_sha1 = {}
114116
# Load the hpc submodules if requested
115117
if args.use_hpc_submodules:
116-
print('Looking for hpc submodule versions')
118+
info = 'Looking for hpc submodule versions'
119+
print(info)
120+
pr_body_text += f"{info}\n"
117121
for submodule in submodules:
118122
sm_name = submodule.name.split('apps/')[-1].replace('_', '').lower()
119123
# This regex assumes the latest date is the last line
@@ -123,9 +127,13 @@ def load_remote(repo, remote, config_tokens):
123127
if sha1 == '':
124128
raise ValueError
125129
submodule_sha1[submodule.name] = sha1
126-
print(f" - Found hpc sha {sha1} for submodule {sm_name}")
130+
info = f" - Found hpc sha {sha1} for submodule {sm_name}"
131+
print(info)
132+
pr_body_text += f"{info}\n"
127133
except:
128-
print(f" - Could not determine hpc version for {sm_name}. Falling back to default behavior.")
134+
info = f" - Could not determine hpc version for {sm_name}. Falling back to default behavior."
135+
print(info)
136+
pr_body_text += f"{info}\n"
129137
continue
130138

131139
# Load the user-provided submodules
@@ -147,7 +155,9 @@ def load_remote(repo, remote, config_tokens):
147155
git_repo.git.fetch(base_remote)
148156
git_repo.git.reset(f'{base_remote}/{base_branch}', hard=True)
149157

150-
print('Updating submodules')
158+
info = 'Updating submodules'
159+
print(info)
160+
pr_body_text += f"{info}\n"
151161
submodules_left = list(submodule_sha1.keys())
152162
for submodule in submodules:
153163
if submodule.name in submodule_sha1:
@@ -156,16 +166,22 @@ def load_remote(repo, remote, config_tokens):
156166
else:
157167
sha1 = 'origin/master'
158168
if args.skip_submodules is not None and submodule.name in args.skip_submodules:
159-
print(f' - {submodule} SKIPPED')
169+
info = f' - {submodule} SKIPPED'
170+
print(info)
171+
pr_body_text += f"{info}\n"
160172
continue
161-
print(f' - {submodule} to {sha1}')
173+
info = f' - {submodule} to {sha1}'
174+
print(info)
175+
pr_body_text += f"{info}\n"
162176
sm_git_repo = git.Repo(os.path.join(repo_path, submodule.path))
163177
sm_git_repo.git.fetch('origin')
164178
sm_git_repo.git.checkout(sha1)
165179
git_repo.git.add(submodule.name)
166180

167181
for submodule_name in submodules_left:
168-
print(f' User-specified submodule {submodule_name} SKIPPED (not a valid submodule)')
182+
info = f' User-specified submodule {submodule_name} SKIPPED (not a valid submodule)'
183+
print(info)
184+
pr_body_text += f"{info}\n"
169185

170186
# If there is a diff between HEAD and the index
171187
# i.e., if there is something to commit
@@ -196,7 +212,7 @@ def load_remote(repo, remote, config_tokens):
196212

197213
if not has_pr:
198214
pr = base_repo_api.create_pull(title='Submodule update',
199-
body='Updates application submodules',
215+
body=pr_body_text,
200216
head=f'{head_namespace}:{head_branch}',
201217
base=base_branch)
202218
print(f'Created pull request {pr.html_url}')

0 commit comments

Comments
 (0)