Skip to content

Commit ac94765

Browse files
gnpriceshivanshsharma13
authored andcommitted
tools [nfc]: Factor out a function to find the Flutter tree
1 parent 27d0037 commit ac94765

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

tools/check

+1-5
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,6 @@ describe_git_head() {
434434
}
435435

436436
print_header() {
437-
local flutter_executable flutter_tree
438-
439437
echo "Test command: ${orig_cmdline}"
440438

441439
echo "Time now: $(date --utc +'%F %T %z')"
@@ -445,9 +443,7 @@ print_header() {
445443
# We avoid `flutter --version` because, weirdly, when run in a
446444
# GitHub Actions step it takes about 30 seconds. (The first time;
447445
# it's fast subsequent times.) That's even after `flutter precache`.
448-
flutter_executable=$(readlink -f "$(type -p flutter)")
449-
flutter_tree=${flutter_executable%/bin/flutter}
450-
describe_git_head "flutter/flutter" "${flutter_tree}"/.git
446+
describe_git_head "flutter/flutter" "$(flutter_tree)"/.git
451447

452448
dart --version
453449
}

tools/lib/git.sh

+10
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,13 @@ git_base_commit() {
9090
git_changed_files() {
9191
git diff --name-only --diff-filter=d "$@"
9292
}
93+
94+
# The root of the active Flutter tree.
95+
#
96+
# (This isn't strictly about Git, but in practice we use it
97+
# mainly for `git --git-dir`.)
98+
flutter_tree() {
99+
local flutter_executable
100+
flutter_executable=$(readlink -f "$(type -p flutter)")
101+
echo "${flutter_executable%/bin/flutter}"
102+
}

0 commit comments

Comments
 (0)