Skip to content

feat: Flag to fetch the diff-base before diffing for if_changed#3689

Merged
DrJosh9000 merged 4 commits intomainfrom
ps-1469-fetch-diff-base
Feb 2, 2026
Merged

feat: Flag to fetch the diff-base before diffing for if_changed#3689
DrJosh9000 merged 4 commits intomainfrom
ps-1469-fetch-diff-base

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?

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
@DrJosh9000 DrJosh9000 force-pushed the ps-1469-fetch-diff-base branch from cfd98a4 to 7beccc1 Compare February 2, 2026 05:25
@DrJosh9000 DrJosh9000 merged commit 19b2657 into main Feb 2, 2026
2 checks passed
@DrJosh9000 DrJosh9000 deleted the ps-1469-fetch-diff-base branch February 2, 2026 05:39
@zhming0 zhming0 mentioned this pull request Feb 3, 2026
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.

2 participants