Skip to content

Commit 1c42d9f

Browse files
author
Vlastimil Zeman
committed
Force setup_submodules.sh use https
1 parent 498bdc0 commit 1c42d9f

File tree

1 file changed

+27
-29
lines changed

1 file changed

+27
-29
lines changed

src/setup_submodules.sh

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,34 @@
11
#!/bin/bash
22

3-
# Initialize both submodules
4-
git submodule init
3+
set -euo pipefail
54

6-
git submodule update ../lib/cbmc
5+
# Initialize submodules
6+
git submodule update --init
77

88
# The forks of diffblue/cbmc that should be fetched into the submodule
99
# allowing for getting commits that aren't yet merged into the upstream fork
10-
req_forks=( "$@" )
1110

12-
cd ../lib/cbmc/
13-
14-
for fork in "${req_forks[@]}"
15-
do
16-
# We should use the following command to check whether the fork exists:
17-
# but it is unreliable so we just assume it exists.
18-
# curl https://api.github.com/repos/$fork/cbmc | jq ".id" -e
19-
# Return code is 0 if the repos exists
20-
21-
# Check whether the specific fork is already a remote
22-
git remote | grep $fork > /dev/null
23-
result=$?
24-
25-
if [ $result -ne 0 ]
26-
then
27-
# Fork not found - add it
28-
echo Adding fork $fork
29-
remote_add_result=`git remote add $fork [email protected]:$fork/cbmc.git`
30-
fi
31-
32-
# Fetch all the forks to ensure we are up to date
33-
echo Fetching fork $fork
34-
git fetch $fork
35-
36-
done
11+
if [ ! -z "$*" ]
12+
then
13+
req_forks=( "$@" )
14+
cd ../lib/cbmc/
15+
for fork in "${req_forks[@]}"
16+
do
17+
# We should use the following command to check whether the fork exists:
18+
# but it is unreliable so we just assume it exists.
19+
# curl https://api.github.com/repos/$fork/cbmc | jq ".id" -e
20+
# Return code is 0 if the repos exists
21+
22+
# Check whether the specific fork is already a remote
23+
if ! git remote | grep "${fork}" > /dev/null
24+
then
25+
# Fork not found - add it
26+
echo Adding fork "${fork}"
27+
git remote add "${fork}" "https://github.com/${fork}/cbmc.git"
28+
fi
29+
30+
# Fetch all the forks to ensure we are up to date
31+
echo Fetching fork "${fork}"
32+
git fetch "${fork}"
33+
done
34+
fi

0 commit comments

Comments
 (0)