Skip to content

Commit a3990b9

Browse files
committed
[update-checkout] Add an option '--dump-hashes' for dumping the checked out hashes for each repo.
I think update-checkout is growing to the point, we should probably rename it to something like repo-tool. The output of this command looks as follows: clang 973bd1a Merge remote-tracking branch 'origin/swift-3.1-branch' into stable cmark 5af77f3 Merge pull request #95 from kainjow/master compiler-rt 1f24bd0 Merge remote-tracking branch 'origin/swift-3.1-branch' into stable llbuild c324ee3 Merge pull request #35 from tinysun212/pr-cygwin-1 lldb f6a5830 Adjust LLDB for changes to the layout of _SwiftTypePreservingNSNumber llvm 52482d0 Merge remote-tracking branch 'origin/swift-3.1-branch' into stable swift 45f3d2a [update-checkout] Add a small tool to dump hashes for all of the checkout repos. swift-corelibs-foundation cc5985e Loopback tests for URLSession (#613) swift-corelibs-libdispatch ba7802e Merge pull request #178 from dgrove-oss/depend-on-swiftc swift-corelibs-xctest 51b419d Merge pull request #174 from modocache/sr-1901-remove-workarounds swift-integration-tests c95c832 Merge pull request #12 from abertelrud/fix-swift-package-init-lib-test swift-xcode-playground-support 4b40c34 Merge pull request #10 from apple/stdlib-unittest-expect-nil swiftpm 65403f5 [ConventionTests] Collect all the diagnostics from PackageBuilder
1 parent 7beb3dd commit a3990b9

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)