Skip to content

Conversation

@natebosch
Copy link
Contributor

@natebosch natebosch commented Nov 7, 2023

Closes #97595

The prior approach of manually diffing the entire log chain is less
efficient, and only found the original branch point ignoring subsequent
merges. The limitation forced PR workflows into rebasing and force
pushing new history to get the branch point far enough for CI to pass.

Use git merge-base to find the latest common commit with the main
branch.
Add an allowFailure argument to the git utility to use a more
specific failure in the case of no shared history when this command will
fail with a generic error.

Use ^branch with the git log commands to exclude shared history and
more easily count the unique commits on each branch.

Drop the Commit abstraction. Parse directly to timestamp or line counts.

Closes #97595

The prior approach of manually diffing the entire log chain is less
efficient, and only found the original branch point ignoring subsequent
merges. The limitation forced PR workflows into rebasing and force
pushing new history to get the branch point far enough for CI to pass.

Use `git merge-base` to find the latest common commit with the main
branch.
Add an `allowFailure` argument to the `git` utility to use a more
specific failure in the case of no shared history when this command will
fail with a generic error.

Use `^branch` with the `git log` commands to exclude shared history and
more easily count the unique commits on each branch.
@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie or stuartmorgan on the #hackers channel in Chat (don't just cc them here, they won't see it! Use Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

The `hash` field is now unused, drop the abstraction instead of wrap a
single time. Count lines directly for the commit counting use case.
This is more direct than log and forcing a single line format,
rev-list uses a single line format by default.
@reidbaker reidbaker self-requested a review November 9, 2023 15:43
Copy link
Contributor

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable to me, but @Hixie should review since he's more familiar with the script and the needs of customer_test.

@stuartmorgan-g stuartmorgan-g requested a review from Hixie November 9, 2023 20:06
@natebosch natebosch added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 9, 2023
@Hixie
Copy link
Contributor

Hixie commented Nov 10, 2023

The git parts of this are all arcane magic to me, unfortunately.

How did you test this? Does it correctly pick the right branch in common cases? What cases would it fail in? Are there cases where this will find a commit that isn't the one that indicates what the branch is up to date to?

Copy link
Contributor

@Hixie Hixie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RSLGTM
...modulo answers to the questions asked above

@auto-submit auto-submit bot merged commit fa3a37c into master Nov 10, 2023
@auto-submit auto-submit bot deleted the find-commit-merge-base branch November 10, 2023 02:15
@natebosch
Copy link
Contributor Author

How did you test this?

Manual testing locally with some repos set up in various states of orphaned or branched and merged commits.

Does it correctly pick the right branch in common cases?

Yes, it seems to pick the correct commit in common cases, and a better commit in merge cases.

What cases would it fail in?

I don't think I can imagine any, AFAICT merge-base does exactly what we'd want based on my understanding of the intent for this tool, but without existing tests I don't know if there is some edge I'm overlooking.

Are there cases where this will find a commit that isn't the one that indicates what the branch is up to date to?

I cannot think of any reason this would find a worse commit than the prior implementation. If there were some workflows where people where explicitly using merge commits and avoiding the rebase because they specifically didn't want the newer commit chosen then those workflows will be broken. I wouldn't expect such a workflow to exist, but I'm more confident on my knowledge of the git side than the flutter CI infrastructure side of this change.

engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 10, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 10, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 10, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 10, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 10, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 10, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 11, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 11, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 12, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 13, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 13, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 13, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 13, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 14, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 14, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 14, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 14, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 14, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App

Projects

None yet

Development

Successfully merging this pull request may close these issues.

customer_testing doesn't update for merges

3 participants