summaryrefslogtreecommitdiff
path: root/bin/pin
blob: 1632132d33ca81a070b17d0600e03be63262166c (plain)
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
#!/bin/bash

set -e -u -o pipefail

debug() {
  if [[ ${LIBYAML_DEBUG_PIN-} ]]; then
    echo "[DEBUG] $*" >&2
  fi
}

warn() {
  echo "$*" >&2
}

tail -n+2 conf/pin.tsv |
tac |
(
  while read -r commit_master commit_code commit_data; do
    line="$commit_master $commit_code $commit_data"

    debug "Line '$line'"
    debug "Checking commit '$commit_master'"
    debug "cd ../..; git merge-base --is-ancestor $commit_master HEAD"

    if (cd ../..; git merge-base --is-ancestor "$commit_master" HEAD 2>/dev/null); then
      debug "Found pinning: '$line'"
      echo "$line"
      exit
    else
      debug "No pinning found"
    fi
  done

  warn 'WARNING: No repository pinning found for libyaml/yaml-test-suite testing.'
  warn 'WARNING: Defaulting to HEAD...'

  echo -e "HEAD\tHEAD\tHEAD"
)