Last active
January 13, 2023 13:33
-
-
Save ardera/4d9807e1cb05b4e26be2133668197768 to your computer and use it in GitHub Desktop.
Finds the latest working flutter gallery commit for a given flutter SDK. For usage, see comments below.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
red=`tput setaf 1` | |
green=`tput setaf 2` | |
nc=`tput sgr0` | |
echo "${green}*** Preparing flutter SDK...${nc}" >/dev/stderr | |
if [[ $# -eq 1 ]]; then | |
ref=$1 | |
echo "${green}*** Using flutter SDK ref \"${ref}\"${nc}" >/dev/stderr | |
sdk_path=$(dirname $(dirname $(which flutter | head -n1))) | |
pushd $sdk_path | |
git fetch &>/dev/stderr | |
git checkout $ref &>/dev/stderr | |
flutter upgrade &>/dev/stderr | |
popd | |
else | |
echo "${green}*** Using flutter stable SDK${nc}" >/dev/stderr | |
flutter channel stable &>/dev/stderr | |
flutter upgrade &>/dev/stderr | |
fi | |
WORK_DIR=`mktemp -d` | |
if [[ ! "$WORK_DIR" || ! -d "$WORK_DIR" ]]; then | |
echo "Could not create temporary directory to clone flutter gallery in." >/dev/stderr | |
exit 1 | |
fi | |
function rm_tmp_dir { | |
rm -rf "$WORK_DIR" &>/dev/stderr | |
} | |
trap rm_tmp_dir EXIT | |
pushd "$WORK_DIR" &>/dev/stderr | |
echo "${green}*** Cloning flutter gallery into $WORK_DIR/gallery...${nc}" >/dev/stderr | |
git clone https://github.com/flutter/gallery.git ./gallery &>/dev/stderr | |
echo "${green}*** Finding latest working flutter gallery commit...${nc}" >/dev/stderr | |
cd gallery &>/dev/stderr | |
for COMMIT in $(git rev-list HEAD) | |
do | |
git checkout --force $COMMIT &> /dev/null | |
if cmd_output=$(flutter analyze .); then | |
echo "${green}*** Found working commit:${nc}" >/dev/stderr | |
echo $COMMIT | |
break | |
else | |
echo "${red}*** Commit $COMMIT does not work.${nc}" >/dev/stderr | |
fi | |
done | |
popd &>/dev/stderr | |
rm_tmp_dir |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Script Usage