Skip to content

[packages] Eliminate tooling dependency on FETCH_HEAD #176738

@stuartmorgan-g

Description

@stuartmorgan-g

The packages tooling used to have a lot of reliance on things like environment variables that were set up at a high level in CI, and then read deep in tooling internals, which made thing hard to reason about when tracing CI behavior, and much harder to replicate locally. Most of that has been eliminated over time, but one remaining one that is a common source of errors for people running the tool locally is the use of FETCH_HEAD.

The behavior is that when the tooling determines git diffs, which is a common use case for some commands, it defaults to FETCH_HEAD if no branch is provided. This is a legacy of when that was the only way the branch was determined, and it was left for CI compatibility. Even in CI this is weird because you need a line like this at a very high level, and then the behavior of a low-level utility class changes based on it. If someone accidentally removed or changed the git fetch command in CI, test behavior in CI would change in non-obvious ways, which is bad.

Locally, it's much worse; falling back to FETCH_HEAD is actively confusing because the chances that FETCH_HEAD is the thing you intended to diff against in normal, local git usage is low, and it's also completely non-obvious what is happening.

We should make a tool-level breaking change that will cause commands than need to diff to fail with a clear error message if no explicit target has been given, so that CI is explicitly indicating what it's doing at the command level, and locally people get useful feedback instead of mysterious behavior.

Metadata

Metadata

Labels

c: contributor-productivityTeam-specific productivity, code health, technical debt.p: toolingAffects the flutter_plugin_tools packagepackageflutter/packages repository. See also p: labels.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions