Skip to content

Fix how we work with PR branch SHA#5304

Merged
premun merged 7 commits intodotnet:mainfrom
premun:prvysoky/last-sha-state
Sep 24, 2025
Merged

Fix how we work with PR branch SHA#5304
premun merged 7 commits intodotnet:mainfrom
premun:prvysoky/last-sha-state

Conversation

@premun
Copy link
Copy Markdown
Member

@premun premun commented Sep 24, 2025

  • We store the PR head branch SHA in a dedicated field
  • We fetch the head branch SHA when we are fetching the PR information (so less queries to GitHub)
  • We update the SHA in Redis accordingly so that later it can be used by merge policies or the codeflow logic where until now we were "abusing" the source SHA field for that.

#5046

Copilot AI review requested due to automatic review settings September 24, 2025 11:05
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors how pull request branch SHA values are handled by introducing a dedicated HeadBranchSha field to properly track the PR head branch SHA separately from the source SHA. Previously, the SourceSha field was being overloaded to store both the build commit SHA and the PR head branch SHA in different contexts.

Key changes:

  • Added HeadBranchSha property to InProgressPullRequest model with proper documentation
  • Updated PR creation and state management to populate and use the dedicated head branch SHA field
  • Simplified conflict detection logic by comparing SHA values directly instead of making additional Git API calls
  • Updated all test files to use the new field structure

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/ProductConstructionService/ProductConstructionService.DependencyFlow/Model/InProgressPullRequest.cs Added HeadBranchSha property with documentation to track PR head branch SHA separately
src/ProductConstructionService/ProductConstructionService.DependencyFlow/PullRequestUpdater.cs Updated PR handling logic to use dedicated head branch SHA field and simplified conflict detection
test/ProductConstructionService.DependencyFlow.Tests/UpdateAssetsForCodeFlowTests.cs Updated test data to include HeadBranchSha field
test/ProductConstructionService.DependencyFlow.Tests/PullRequestUpdaterTests.cs Updated test setup and mocking to handle new SHA field structure
test/ProductConstructionService.DependencyFlow.Tests/PullRequestCommentBuilderTests.cs Updated test PR objects to separate head branch SHA from source SHA
test/ProductConstructionService.DependencyFlow.Tests/PendingCodeFlowUpdatesTests.cs Updated test parameter names and removed unused import
test/ProductConstructionService.DependencyFlow.Tests/MergePolicyEvaluationTests.cs Updated merge policy tests to use head branch SHA and removed unused import

adamzip
adamzip previously approved these changes Sep 24, 2025
Copy link
Copy Markdown
Contributor

@adamzip adamzip left a comment

Choose a reason for hiding this comment

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

approving with 1 minor suggestion

@premun premun merged commit b5c2541 into dotnet:main Sep 24, 2025
9 checks passed
@premun premun deleted the prvysoky/last-sha-state branch September 24, 2025 12:45
premun added a commit to premun/arcade-services that referenced this pull request Sep 25, 2025
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.

3 participants