* [tool] Improve main-branch detection
Currently main-branch detection for `--packages-for-branch` looks at
branch names, but this no longer works on LUCI which now seems to be
checking out specific hashes rather than branches. This updates the
behavior so that it will treat any hash that is an ancestor of `main` as
being part of `main`, which should allow post-submit detection to work
under LUCI.
Fixes https://github.com/flutter/flutter/issues/119330
* Fix throw
* Fix typos
* Update comment