Skip to content

Commit

Permalink
tools [nfc]: Factor out a function to find the Flutter tree
Browse files Browse the repository at this point in the history
  • Loading branch information
gnprice committed Dec 9, 2024
1 parent 489a699 commit e6932fb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 1 addition & 5 deletions tools/check
Original file line number Diff line number Diff line change
Expand Up @@ -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')"
Expand All @@ -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
}
Expand Down
10 changes: 10 additions & 0 deletions tools/lib/git.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
}

0 comments on commit e6932fb

Please sign in to comment.