summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIngy döt Net <ingy@ingy.net>2020-05-25 11:47:59 -0700
committerIngy döt Net <ingy@ingy.net>2020-05-25 11:47:59 -0700
commit787f7ddf00400c30843c38c27caa083a90e2f45f (patch)
treeadd74afdd14c838d23350b0a0abef2440a99022d
parent6078085624593350f0cc126b48bec7e64d0f0715 (diff)
downloadlibyaml-git-787f7ddf00400c30843c38c27caa083a90e2f45f.tar.gz
Refactor bin/pin
-rwxr-xr-xbin/pin33
1 files changed, 24 insertions, 9 deletions
diff --git a/bin/pin b/bin/pin
index 005c6dd..7393be1 100755
--- a/bin/pin
+++ b/bin/pin
@@ -1,22 +1,37 @@
#!/bin/bash
-tac conf/pin.tsv |
+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 line; do
- commit_master=$(echo "$line" | cut -f1)
+ 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"
- echo "[debug] line $line" >&2
- echo "[debug] Trying commit $commit_master" >&2
- echo "[debug] cd ../..; git merge-base --is-ancestor $commit_master HEAD" >&2
- (cd ../..; git merge-base --is-ancestor "$commit_master" HEAD || echo "no" >&2)
if (cd ../..; git merge-base --is-ancestor "$commit_master" HEAD 2>/dev/null); then
echo "$line"
exit
+ else
+ debug "Not found"
fi
done
- echo 'WARNING: No repository pinning found for libyaml/yaml-test-suite testing.' >&2
- echo 'WARNING: Defaulting to HEAD...' >&2
+ warn 'WARNING: No repository pinning found for libyaml/yaml-test-suite testing.'
+ warn 'WARNING: Defaulting to HEAD...'
echo -e "HEAD\tHEAD\tHEAD"
)