|
1 | 1 | #!/bin/bash
|
2 | 2 |
|
3 |
| -# Initialize both submodules |
4 |
| -git submodule init |
| 3 | +set -euo pipefail |
5 | 4 |
|
6 |
| -git submodule update ../lib/cbmc |
| 5 | +# Initialize submodules |
| 6 | +git submodule update --init |
7 | 7 |
|
8 | 8 | # The forks of diffblue/cbmc that should be fetched into the submodule
|
9 | 9 | # allowing for getting commits that aren't yet merged into the upstream fork
|
10 |
| -req_forks=( "$@" ) |
11 | 10 |
|
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