Skip to content

Commit 1a03db4

Browse files
authored
Merge pull request #5056 from gottesmm/update-checkout-dump-repo-hashes
[update-checkout] Add an option '--dump-hashes' for dumping the check…
2 parents 79cd818 + a3990b9 commit 1a03db4

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

utils/update-checkout

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,20 @@ def obtain_additional_swift_sources(
171171
echo=False)
172172

173173

174+
def dump_repo_hashes(config):
175+
max_len = reduce(lambda acc, x: max(acc, len(x)),
176+
config['repos'].keys(), 0)
177+
fmt = "{:<%r}{}" % (max_len+5)
178+
for repo_name, repo_info in sorted(config['repos'].items(),
179+
key=lambda x: x[0]):
180+
with shell.pushd(os.path.join(SWIFT_SOURCE_ROOT, repo_name),
181+
dry_run=False,
182+
echo=False):
183+
h = shell.capture(["git", "log", "--oneline", "-n", "1"],
184+
echo=False).strip()
185+
print(fmt.format(repo_name, h))
186+
187+
174188
def validate_config(config):
175189
# Make sure that our branch-names are unique.
176190
scheme_names = config['branch-schemes'].keys()
@@ -241,7 +255,11 @@ By default, updates your checkouts of Swift, SourceKit, LLDB, and SwiftPM.""")
241255
help="""Check out related pull requests referenced in the given
242256
free-form GitHub-style comment.""",
243257
metavar='GITHUB-COMMENT',
244-
dest='github_comment')
258+
dest='github_comment'),
259+
parser.add_argument(
260+
'--dump-hashes',
261+
action='store_true',
262+
help='Dump the git hashes of all repositories being tracked')
245263
args = parser.parse_args()
246264

247265
clone = args.clone
@@ -254,6 +272,10 @@ By default, updates your checkouts of Swift, SourceKit, LLDB, and SwiftPM.""")
254272
config = json.load(f)
255273
validate_config(config)
256274

275+
if args.dump_hashes:
276+
dump_repo_hashes(config)
277+
return 0
278+
257279
cross_repos_pr = {}
258280
if github_comment:
259281
regex_pr = r'(apple/[-a-zA-Z0-9_]+/pull/\d+|apple/[-a-zA-Z0-9_]+#\d+)'

0 commit comments

Comments
 (0)