Skip to content

Commit c4fb200

Browse files
committed
Retries 5 times and then outputs the fetching error
1 parent 3f86977 commit c4fb200

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

bin/gpm

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,18 @@ set_dependencies() {
4646
while read package version; do
4747
(
4848
local install_path="${GOPATH%%:*}/src/${package%%/...}"
49-
is_in_use $install_path && wait
50-
5149
echo ">> Getting package "$package""
52-
while true; do go get -u -d "$package" 2> /dev/null && break; done
50+
51+
# Retries in case of possible race conditions when installing a package
52+
# dependency
53+
for ((i=0; i<5; i++)); do
54+
out=$(go get -u -d "$package" 2>&1 >/dev/null) && break
55+
done
56+
[[ $? != 0 ]] && echo "-- Failed to get "$package", error: " && echo "$out" && exit 1
5357

5458
echo ">> Setting $package to version $version"
5559
cd $install_path
60+
is_in_use $install_path && wait
5661

5762
[ -d .hg ] && hg update -q "$version"
5863
[ -d .git ] && git checkout -q "$version"

0 commit comments

Comments
 (0)