File: pin-ci.sh

package info (click to toggle)
coq-doc 8.16.1-1
  • links: PTS, VCS
  • area: non-free
  • in suites: bookworm
  • size: 42,788 kB
  • sloc: ml: 219,673; sh: 4,035; python: 3,372; ansic: 2,529; makefile: 728; lisp: 279; javascript: 87; xml: 24; sed: 2
file content (44 lines) | stat: -rwxr-xr-x 1,188 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env bash

# Use this script to pin the commit used by the developments tracked by the CI

OVERLAYS="./dev/ci/ci-basic-overlay.sh"

process_development() {
  local DEV=$1
  local REPO_VAR="${DEV}_CI_GITURL"
  local REPO=${!REPO_VAR}
  local BRANCH_VAR="${DEV}_CI_REF"
  local BRANCH=${!BRANCH_VAR}
  if [[ -z "$BRANCH" ]]
  then
    echo "$DEV has no branch set, skipping"
    return 0
  fi
  if [[ $BRANCH =~ ^[a-f0-9]{40}$ ]]
  then
    echo "$DEV is already set to hash $BRANCH, skipping"
    return 0
  fi
  echo "Resolving $DEV as $BRANCH from $REPO"
  local HASH=$(git ls-remote --heads $REPO $BRANCH | cut -f 1)
  if [[ -z "$HASH" ]]
  then
    echo "Could not resolve reference $BRANCH for $DEV (something went wrong), skipping"
    return 0
  fi
  read -p "Expand $DEV from $BRANCH to $HASH? [y/N] " -n 1 -r
  echo
  if [[ $REPLY =~ ^[Yy]$ ]]; then
    # use -i.bak to be compatible with MacOS; see, e.g., https://stackoverflow.com/a/7573438/377022
    sed -i.bak -E "s|project +$DEV +.*|project $DEV '$REPO' '$HASH'|" $OVERLAYS
  fi
}

# Execute the script to set the overlay variables
. $OVERLAYS

for project in ${projects[@]}
do
  process_development $project
done