Skip to content

Conversation

@DrJosh9000
Copy link
Contributor

@DrJosh9000 DrJosh9000 commented Jan 29, 2026

Description

if_changed assumes that both the diff-base exists locally and is reasonably up-to-date; for some branches this has a reasonable chance of being true, but (especially if) --git-diff-base has been set to some custom value then the probability drops quite a bit.

This change adds a new flag, --fetch-diff-base, with corresponding env var BUIDLKITE_FETCH_DIFF_BASE, that runs git fetch -- remote refspec before doing the git diff.

Open question

Should this new flag be enabled by default? It's probably fine?

Context

Using this new flag would fix #3602

https://linear.app/buildkite/issue/PS-1469
https://linear.app/buildkite/issue/PS-1595

Changes

  • Adds the flag
  • Adds the implementation
  • A little refactoring

Testing

  • Tests have run locally (with go test ./...). Buildkite employees may check this if the pipeline has run automatically.
  • Code is formatted (with go tool gofumpt -extra -w .)

Disclosures / Credits

I did not use AI tools at all

@DrJosh9000 DrJosh9000 force-pushed the ps-1469-fetch-diff-base branch 3 times, most recently from b11279c to 203d29d Compare January 29, 2026 05:33
@DrJosh9000 DrJosh9000 requested a review from a team January 29, 2026 05:38
@DrJosh9000 DrJosh9000 force-pushed the ps-1469-fetch-diff-base branch from 203d29d to cfd98a4 Compare January 29, 2026 05:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

With default fetch flags, the if_changed logic will fail for merge bases or default branches that have not been fetched.

1 participant