-
Notifications
You must be signed in to change notification settings - Fork 155
Expand file tree
/
Copy pathcheckout
More file actions
executable file
·80 lines (66 loc) · 2.59 KB
/
Copy pathcheckout
File metadata and controls
executable file
·80 lines (66 loc) · 2.59 KB
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
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env python3
# ===--- checkout --------------------------------------------------------===
#
# This source file is part of the Swift.org open source project
#
# Copyright (c) 2014 - 2022 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 os
import argparse
import platform
import shutil
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."
)
projects_group = parser.add_mutually_exclusive_group(required=True)
projects_group.add_argument('--projects',
metavar='PATH',
help='JSON project file',
type=os.path.abspath)
projects_group.add_argument('--projects-dir',
metavar='PATH',
help='directory of per-project JSON files',
type=os.path.abspath)
parser.add_argument('--project-path',
metavar='PATH',
help='only checkout this project',
default=[],
action='append')
return parser.parse_args()
def main():
"""Clone and checkout pinned commits for indexed projects."""
os.chdir(os.path.dirname(__file__))
args = parse_args()
index = project.load_projects(args)
root_path = common.private_workspace('project_cache')
total_repos = 0
if os.path.exists(root_path):
shutil.rmtree(root_path, onerror=common.onerror)
os.makedirs(root_path, exist_ok=True)
for repo in index:
if args.project_path and repo['path'] not in args.project_path:
continue
# Skip repos that aren't supported on the platform
if platform.system() not in repo['platforms']:
continue
for compatible_swift in repo['compatibility']:
project.checkout(root_path, repo, compatible_swift['commit'])
total_repos += 1
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())