From e6932fb96c33b20ec9d687c8febee0abf083a571 Mon Sep 17 00:00:00 2001 From: Greg Price Date: Sun, 8 Dec 2024 18:19:11 -0800 Subject: [PATCH] tools [nfc]: Factor out a function to find the Flutter tree --- tools/check | 6 +----- tools/lib/git.sh | 10 ++++++++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/tools/check b/tools/check index a5e5962cb2..6a0cdb35d0 100755 --- a/tools/check +++ b/tools/check @@ -434,8 +434,6 @@ describe_git_head() { } print_header() { - local flutter_executable flutter_tree - echo "Test command: ${orig_cmdline}" echo "Time now: $(date --utc +'%F %T %z')" @@ -445,9 +443,7 @@ print_header() { # We avoid `flutter --version` because, weirdly, when run in a # GitHub Actions step it takes about 30 seconds. (The first time; # it's fast subsequent times.) That's even after `flutter precache`. - flutter_executable=$(readlink -f "$(type -p flutter)") - flutter_tree=${flutter_executable%/bin/flutter} - describe_git_head "flutter/flutter" "${flutter_tree}"/.git + describe_git_head "flutter/flutter" "$(flutter_tree)"/.git dart --version } diff --git a/tools/lib/git.sh b/tools/lib/git.sh index 1fa254e1a4..cff123b371 100644 --- a/tools/lib/git.sh +++ b/tools/lib/git.sh @@ -90,3 +90,13 @@ git_base_commit() { git_changed_files() { git diff --name-only --diff-filter=d "$@" } + +# The root of the active Flutter tree. +# +# (This isn't strictly about Git, but in practice we use it +# mainly for `git --git-dir`.) +flutter_tree() { + local flutter_executable + flutter_executable=$(readlink -f "$(type -p flutter)") + echo "${flutter_executable%/bin/flutter}" +}