Skip to content

Commit 0189cec

Browse files
committed
Auto merge of #42665 - aidanhs:aphs-simplify-init-repos, r=Mark-Simulacrum
Use --depth to speed up pristine submodule cloning In addition, remove all the unused cache stuff r? @Mark-Simulacrum
2 parents 554c685 + d0c1e64 commit 0189cec

File tree

1 file changed

+4
-35
lines changed

1 file changed

+4
-35
lines changed

src/ci/init_repo.sh

+4-35
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ REPO_DIR="$1"
2222
CACHE_DIR="$2"
2323

2424
cache_src_dir="$CACHE_DIR/src"
25-
# If the layout of the cache directory changes, bump the number here
26-
# (and anywhere else this file is referenced) so the cache is wiped
27-
cache_valid_file="$CACHE_DIR/cache_valid1"
2825

2926
if [ ! -d "$REPO_DIR" -o ! -d "$REPO_DIR/.git" ]; then
3027
echo "Error: $REPO_DIR does not exist or is not a git repo"
@@ -36,47 +33,19 @@ if [ ! -d "$CACHE_DIR" ]; then
3633
exit 1
3734
fi
3835

39-
# Wipe the cache if it's not valid, or mark it as invalid while we update it
40-
if [ ! -f "$cache_valid_file" ]; then
41-
echo "Invalid cache, wiping ($cache_valid_file missing)"
42-
rm -rf "$CACHE_DIR"
43-
mkdir "$CACHE_DIR"
44-
else
45-
# Ignore errors while gathering information about the possible brokenness
46-
# of the git repo since our gathered info will tell us something is wrong
47-
set +o errexit
48-
stat_lines=$(cd "$cache_src_dir" && git status --porcelain | wc -l)
49-
stat_ec=$(cd "$cache_src_dir" && git status >/dev/null 2>&1; echo $?)
50-
set -o errexit
51-
if [ ! -d "$cache_src_dir/.git" -o $stat_lines != 0 -o $stat_ec != 0 ]; then
52-
# Something is badly wrong - the cache valid file is here, but something
53-
# about the git repo is fishy. Nuke it all, just in case
54-
echo "WARNING: $cache_valid_file exists but bad repo: l:$stat_lines, ec:$stat_ec"
55-
rm -rf "$CACHE_DIR"
56-
mkdir "$CACHE_DIR"
57-
else
58-
echo "Valid cache ($cache_valid_file exists)"
59-
rm "$cache_valid_file"
60-
fi
61-
fi
36+
rm -rf "$CACHE_DIR"
37+
mkdir "$CACHE_DIR"
6238

6339
travis_fold start update_cache
6440
travis_time_start
6541

6642
# Update the cache (a pristine copy of the rust source master)
67-
if [ ! -d "$cache_src_dir/.git" ]; then
68-
retry sh -c "rm -rf $cache_src_dir && mkdir -p $cache_src_dir && \
69-
git clone https://github.com/rust-lang/rust.git $cache_src_dir"
70-
fi
71-
retry sh -c "cd $cache_src_dir && git reset --hard && git pull"
43+
retry sh -c "rm -rf $cache_src_dir && mkdir -p $cache_src_dir && \
44+
git clone --depth 1 https://github.com/rust-lang/rust.git $cache_src_dir"
7245
(cd $cache_src_dir && git rm src/llvm)
7346
retry sh -c "cd $cache_src_dir && \
7447
git submodule deinit -f . && git submodule sync && git submodule update --init"
7548

76-
# Cache was updated without errors, mark it as valid
77-
echo "Refreshed cache (touch $cache_valid_file)"
78-
touch "$cache_valid_file"
79-
8049
travis_fold end update_cache
8150
travis_time_finish
8251

0 commit comments

Comments
 (0)