Skip to content

Instantly share code, notes, and snippets.

@bbannier
Last active September 18, 2019 12:54
Show Gist options
  • Save bbannier/f19dfc0bdd65a2d7977ff3f2624aa990 to your computer and use it in GitHub Desktop.
Save bbannier/f19dfc0bdd65a2d7977ff3f2624aa990 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -eux
DCOS="$HOME"/src/dcos
MESOS="$HOME"/src/mesos
COMMIT=$1
# Check if Mesos commit $1 contains $2.
contains() {
git --git-dir="$MESOS"/.git rev-list "$1" | grep -q "$2"
}
# Check if commit has already landed in dcos.
contains "$(jq -r '.single_source.ref' "$DCOS"/packages/mesos/buildinfo.json)" "$COMMIT" || (echo "$COMMIT has not landed" && exit 1)
LAST_REV=
for rev in $(git --git-dir="$DCOS/.git" rev-list HEAD -- packages/mesos/buildinfo.json); do
LAST_REV="$rev"
contains "$(git show "$rev":packages/mesos/buildinfo.json | jq -r '.single_source.ref')" "$COMMIT" || break
done
if [ -z "$LAST_REV" ]; then
echo "Could not find commit introducing $COMMIT"
exit 1
fi
git --git-dir="$DCOS/.git" show "$LAST_REV"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment