Skip to content

Commit

Permalink
[update-checkout] Add an option '--dump-hashes' for dumping the check…
Browse files Browse the repository at this point in the history
…ed 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 swiftlang#95 from kainjow/master
compiler-rt                        1f24bd0 Merge remote-tracking branch 'origin/swift-3.1-branch' into stable
llbuild                            c324ee3 Merge pull request swiftlang#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 (swiftlang#613)
swift-corelibs-libdispatch         ba7802e Merge pull request swiftlang#178 from dgrove-oss/depend-on-swiftc
swift-corelibs-xctest              51b419d Merge pull request swiftlang#174 from modocache/sr-1901-remove-workarounds
swift-integration-tests            c95c832 Merge pull request swiftlang#12 from abertelrud/fix-swift-package-init-lib-test
swift-xcode-playground-support     4b40c34 Merge pull request swiftlang#10 from apple/stdlib-unittest-expect-nil
swiftpm                            65403f5 [ConventionTests] Collect all the diagnostics from PackageBuilder
  • Loading branch information
gottesmm committed Sep 28, 2016
1 parent 7beb3dd commit a3990b9
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion utils/update-checkout
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand All @@ -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+)'
Expand Down

0 comments on commit a3990b9

Please sign in to comment.