forked from swiftlang/swift-source-compat-suite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkout
executable file
·70 lines (58 loc) · 2.25 KB
/
checkout
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env python
# ===--- checkout --------------------------------------------------------===
#
# This source file is part of the Swift.org open source project
#
# Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
# Licensed under Apache License v2.0 with Runtime Library Exception
#
# See https://swift.org/LICENSE.txt for license information
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
#
# ===----------------------------------------------------------------------===
"""Clone and checkout pinned commits for indexed projects."""
import json
import os
import argparse
import sys
import common
import project
def parse_args():
"""Return parsed command line arguments."""
parser = argparse.ArgumentParser(
description="Clone and checkout pinned commits for indexed projects."
)
parser.add_argument('--projects',
metavar='PATH',
required=True,
help='JSON project file',
type=os.path.abspath)
parser.add_argument('--project-path',
metavar='PATH',
help='only checkout this project')
return parser.parse_args()
def main():
"""Clone and checkout pinned commits for indexed projects."""
os.chdir(os.path.dirname(__file__))
args = parse_args()
index = json.loads(open(args.projects).read())
root_path = common.private_workspace('project_cache')
total_repos = 0
if os.path.exists(root_path):
common.check_execute(['chflags', '-R', 'nouchg', root_path])
common.check_execute(['rm', '-rf', root_path])
common.check_execute(['mkdir', '-p', root_path])
for repo in index:
if args.project_path and args.project_path != repo['path']:
continue
total_repos += 1
for compatible_swift in repo['compatibility']:
project.checkout(root_path, repo,
repo['compatibility'][compatible_swift]['commit'])
common.debug_print('='*40)
common.debug_print('Repository Summary:')
common.debug_print(' Total: %s' % total_repos)
common.debug_print('='*40)
return 0
if __name__ == '__main__':
sys.exit(main())