Skip to content

Persist the base commit of subscription update for diff links #4870

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

adamzip
Copy link
Contributor

@adamzip adamzip commented May 22, 2025

#4777 (comment)

Persist the original base commit throughout subsequent subscription updates on the same open PR in order to generate the right commit diff url.

Example PR: maestro-auth-test/maestro-test-vmr#1850

@adamzip adamzip requested a review from premun May 22, 2025 10:43
@adamzip adamzip self-assigned this May 22, 2025
@Copilot Copilot AI review requested due to automatic review settings May 22, 2025 10:43
Copy link
Contributor

@Copilot 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 ensures that the original base commit SHA for a subscription is persisted across multiple updates on the same pull request, enabling correct diff link generation.

  • Adds a BaseSourceSha property to the subscription update model.
  • Populates BaseSourceSha when creating and updating code‐flow pull requests.
  • Passes BaseSourceSha into the PR title/description builder for accurate diff URLs.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/ProductConstructionService/.../SubscriptionPullRequestUpdate.cs Added BaseSourceSha DataMember to track original commit
src/ProductConstructionService/.../PullRequestUpdater.cs Computes and assigns BaseSourceSha in create/update flows
Comments suppressed due to low confidence (1)

src/ProductConstructionService/ProductConstructionService.DependencyFlow/PullRequestUpdater.cs:1114

  • Consider adding unit tests to verify that BaseSourceSha is correctly retrieved for existing subscriptions and falls back to previousSourceSha when absent.
string? baseSourceSha= pullRequest.ContainedSubscriptions.FirstOrDefault(u => u.SubscriptionId.Equals(update.SubscriptionId))?.BaseSourceSha

@@ -20,4 +20,7 @@ public class SubscriptionPullRequestUpdate

[DataMember]
public string CommitSha { get; set; }

Copy link
Preview

Copilot AI May 22, 2025

Choose a reason for hiding this comment

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

[nitpick] Add XML documentation for BaseSourceSha explaining that it holds the original base commit SHA used for generating diffs.

Suggested change
/// <summary>
/// Gets or sets the original base commit SHA used for generating diffs.
/// </summary>

Copilot uses AI. Check for mistakes.

Copy link
Member

Choose a reason for hiding this comment

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

This would be nice to add

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a bit difficult to describe. I'm thinking "The earliest commit in the source repository from the changes contained in the current PR".
While writing this, I realize that this property is a bit out of place - technically, SubscriptionPullRequestUpdate shouldn't depend on any PR state - it only represents a single subscription update (i.e. changes from one subscription trigger), while BaseSourceSha only makes sense in the context of the PR

Copy link
Member

Choose a reason for hiding this comment

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

That's a good point. Why isn't it in the InProgressPullRequest?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll change it

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.

2 participants