Skip to content

Commit 7a0b677

Browse files
committed
Merge pull request swiftlang#1486 from shahmishal/swift-2.2-branch
Sync utils/update-checkout with master
2 parents b316a3f + ee924ad commit 7a0b677

File tree

1 file changed

+37
-27
lines changed

1 file changed

+37
-27
lines changed

utils/update-checkout

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ from SwiftBuildSupport import (
2424
check_output,
2525
)
2626

27+
REPOSITORIES = {
28+
'llvm': 'apple/swift-llvm',
29+
'clang': 'apple/swift-clang',
30+
'swift': 'apple/swift-swift',
31+
'lldb': 'apple/swift-lldb',
32+
'cmark': 'apple/swift-cmark',
33+
'swift-integration-tests': 'apple/swift-integration-tests',
34+
}
35+
2736
def update_working_copy(repo_path, branch):
2837
if not os.path.isdir(repo_path):
2938
return
@@ -44,23 +53,23 @@ def update_working_copy(repo_path, branch):
4453
check_call(["git", "fetch"])
4554
check_call(["git", "rebase", "FETCH_HEAD"])
4655

47-
def obtain_additional_swift_sources(with_ssh, branch):
48-
additional_repos = {
49-
'llvm': 'apple/swift-llvm',
50-
'clang': 'apple/swift-clang',
51-
'lldb': 'apple/swift-lldb',
52-
'cmark': 'apple/swift-cmark',
53-
'swift-integration-tests': 'apple/swift-integration-tests',
54-
}
55-
for dir_name, repo in additional_repos.items():
56+
def obtain_additional_swift_sources(
57+
with_ssh, branch, skip_history, skip_repositories):
58+
for dir_name, repo in REPOSITORIES.items():
59+
if dir_name in skip_repositories:
60+
print("--- Skipping '" + dir_name + "' ---")
61+
continue
5662
with WorkingDirectory(SWIFT_SOURCE_ROOT):
5763
if not os.path.isdir(os.path.join(dir_name, ".git")):
5864
print("--- Cloning '" + dir_name + "' ---")
5965
if with_ssh is True:
6066
remote = "git@github.com:" + repo + '.git'
6167
else:
6268
remote = "https://github.com/" + repo + '.git'
63-
check_call(['git', 'clone', remote, dir_name])
69+
if skip_history:
70+
check_call(['git', 'clone', '--depth', '1', remote, dir_name])
71+
else:
72+
check_call(['git', 'clone', remote, dir_name])
6473
if branch:
6574
src_path = SWIFT_SOURCE_ROOT + "/" + dir_name + "/" + ".git"
6675
check_call(['git', '--git-dir', src_path, '--work-tree', os.path.join(SWIFT_SOURCE_ROOT, dir_name), 'checkout', branch])
@@ -71,38 +80,39 @@ def main():
7180
description="""
7281
repositories.
7382
74-
By default, updates your checkouts of Swift, and LLDB.""")
75-
parser.add_argument("-a", "--all",
76-
help="also update checkouts of LLVM, and Clang",
77-
action="store_true")
83+
By default, updates your checkouts of Swift, SourceKit, LLDB, and SwiftPM.""")
7884
parser.add_argument("--clone",
7985
help="Obtain Sources for Swift and Related Projects",
8086
action="store_true")
8187
parser.add_argument("--clone-with-ssh",
8288
help="Obtain Sources for Swift and Related Projects via SSH",
8389
action="store_true")
90+
parser.add_argument("--skip-history",
91+
help="Skip histories when obtaining sources",
92+
action="store_true")
93+
parser.add_argument("--skip-repository",
94+
metavar="DIRECTORY",
95+
default=[],
96+
help="Skip the specified repository",
97+
action="append")
8498
parser.add_argument("--branch",
8599
help="Obtain Sources for specific branch")
86100
args = parser.parse_args()
87101

88102
clone = args.clone
89103
clone_with_ssh = args.clone_with_ssh
104+
skip_history = args.skip_history
90105
branch = args.branch
91106

92107
if clone or clone_with_ssh:
93-
obtain_additional_swift_sources(clone_with_ssh, branch)
94-
return 0
95-
96-
if args.all:
97-
update_working_copy(os.path.join(SWIFT_SOURCE_ROOT, "llvm"), branch)
98-
update_working_copy(os.path.join(SWIFT_SOURCE_ROOT, "clang"), branch)
99-
100-
update_working_copy(os.path.join(SWIFT_SOURCE_ROOT, "swift"), branch)
101-
update_working_copy(
102-
os.path.join(SWIFT_SOURCE_ROOT, "swift", "benchmark", "PerfTestSuite"), branch)
103-
update_working_copy(os.path.join(SWIFT_SOURCE_ROOT, "cmark"), branch)
104-
update_working_copy(os.path.join(SWIFT_SOURCE_ROOT, "lldb"), branch)
105-
update_working_copy(os.path.join(SWIFT_SOURCE_ROOT, "swift-integration-tests"), branch)
108+
obtain_additional_swift_sources(
109+
clone_with_ssh, branch, skip_history, args.skip_repository)
110+
111+
for dir_name, _ in REPOSITORIES.items():
112+
if dir_name in args.skip_repository:
113+
print("--- Skipping '" + dir_name + "' ---")
114+
continue
115+
update_working_copy(os.path.join(SWIFT_SOURCE_ROOT, dir_name), branch)
106116

107117
return 0
108118

0 commit comments

Comments
 (0)