Debian Codegraph @

dev/tools/pin-ci.sh

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
•1 #!/usr/bin/bash
2
3 # Use this script to pin the commit used by the developments tracked by the CI
4
5 OVERLAYS="./dev/ci/ci-basic-overlay.sh"
6
7 process_development() {
8 local DEV=$1
9 local REPO_VAR="${DEV}_CI_GITURL"
10 local REPO=${!REPO_VAR}
11 local BRANCH_VAR="${DEV}_CI_REF"
12 local BRANCH=${!BRANCH_VAR}
13 local HASH
14 if [[ -z "$BRANCH" ]]
15 then
16 echo "$DEV has no branch set, skipping"
17 return 0
18 fi
19 if [[ $BRANCH =~ ^[a-f0-9]{40}$ ]]
20 then
21 echo "$DEV is already set to hash $BRANCH, skipping"
22 return 0
23 fi
24 echo "Resolving $DEV as $BRANCH from $REPO"
25 HASH=$(git ls-remote --heads "$REPO" "$BRANCH" | cut -f 1)
26 if [[ -z "$HASH" ]]
27 then
28 echo "Could not resolve reference $BRANCH for $DEV (something went wrong), skipping"
29 return 0
30 fi
31 echo "Expandin $DEV from $BRANCH to $HASH"
32 # use -i.bak to be compatible with MacOS; see, e.g., https://stackoverflow.com/a/7573438/377022
33 sed -i.bak -E "s|project +$DEV +.*|project $DEV '$REPO' '$HASH'|" $OVERLAYS
34 }
35
36 # Execute the script to set the overlay variables
37 . $OVERLAYS
38
39 for project in "${projects[@]}"
40 do
41 process_development "$project"
42 done