From a3990b93fe3d97036625b34375b807bc568cb021 Mon Sep 17 00:00:00 2001 From: Michael Gottesman Date: Wed, 28 Sep 2016 15:13:24 -0700 Subject: [PATCH] [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 --- utils/update-checkout | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/utils/update-checkout b/utils/update-checkout index aa4be465998bc..060f08ec2fab6 100755 --- a/utils/update-checkout +++ b/utils/update-checkout @@ -171,6 +171,20 @@ def obtain_additional_swift_sources( echo=False) +def dump_repo_hashes(config): + max_len = reduce(lambda acc, x: max(acc, len(x)), + config['repos'].keys(), 0) + fmt = "{:<%r}{}" % (max_len+5) + for repo_name, repo_info in sorted(config['repos'].items(), + key=lambda x: x[0]): + with shell.pushd(os.path.join(SWIFT_SOURCE_ROOT, repo_name), + dry_run=False, + echo=False): + h = shell.capture(["git", "log", "--oneline", "-n", "1"], + echo=False).strip() + print(fmt.format(repo_name, h)) + + def validate_config(config): # Make sure that our branch-names are unique. scheme_names = config['branch-schemes'].keys() @@ -241,7 +255,11 @@ By default, updates your checkouts of Swift, SourceKit, LLDB, and SwiftPM.""") help="""Check out related pull requests referenced in the given free-form GitHub-style comment.""", metavar='GITHUB-COMMENT', - dest='github_comment') + dest='github_comment'), + parser.add_argument( + '--dump-hashes', + action='store_true', + help='Dump the git hashes of all repositories being tracked') args = parser.parse_args() clone = args.clone @@ -254,6 +272,10 @@ By default, updates your checkouts of Swift, SourceKit, LLDB, and SwiftPM.""") config = json.load(f) validate_config(config) + if args.dump_hashes: + dump_repo_hashes(config) + return 0 + cross_repos_pr = {} if github_comment: regex_pr = r'(apple/[-a-zA-Z0-9_]+/pull/\d+|apple/[-a-zA-Z0-9_]+#\d+)'