Skip to content

[Claude code generated PR] Extract isLatestInMajor helper in build-cli#26589

Merged
dhr-verma merged 17 commits intomicrosoft:mainfrom
dhr-verma:dhr-verma/extractLatestVersionHelper
Mar 2, 2026
Merged

[Claude code generated PR] Extract isLatestInMajor helper in build-cli#26589
dhr-verma merged 17 commits intomicrosoft:mainfrom
dhr-verma:dhr-verma/extractLatestVersionHelper

Conversation

@dhr-verma
Copy link
Copy Markdown
Contributor

Summary

  • Extracted the duplicated "latest stable version by major" logic (~40 LOC) from check/latestVersions and vnext/check/latestVersions into a shared pure helper isLatestInMajor in src/library/latestVersions.ts
  • Both commands now delegate to the helper; all log strings and ADO pipeline variable output are preserved unchanged
  • Added unit tests for the new helper covering all result branches (isLatest true, false with newer stable, false with no stable for major, internal version filtering, unsorted input, empty list, all-internal list)

Test plan

  • pnpm run build:compile passes
  • pnpm run test passes (403/404; pre-existing flaky git lock failure unrelated to this change)
  • pnpm run lint:fix clean
  • Both check:latestVersions and vnext:check:latestVersions delegate to isLatestInMajor with identical log output

Related

Closes #26536

🤖 Generated with Claude Code

dhr-verma and others added 17 commits February 10, 2026 12:17
…aily-repo-status.md-4130

Add agentic workflow daily-repo-status
…ode-simplifier.md-1519

Add agentic workflow code-simplifier
…uplicate-code-detector.md-4767

Add agentic workflow duplicate-code-detector
…to vermadhr/ghawWorkflowsForSimplification
…ication

Vermadhr/ghaw workflows for simplification
…icate deployment logic

Extracts the repeated "latest stable version by major" computation from
check/latestVersions and vnext/check/latestVersions into a shared pure
helper in src/library/latestVersions.ts. Adds unit tests covering all
result branches.

Closes microsoft#26536

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings February 27, 2026 22:11
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 build-cli’s “latest stable version by major” decision logic by extracting it from two check commands into a shared pure helper, and adds unit coverage for the helper.

Changes:

  • Added isLatestInMajor helper (and result type) under src/library/latestVersions.ts.
  • Updated both check:latestVersions and vnext:check:latestVersions commands to delegate to the helper while preserving existing log/ADO variable output.
  • Added unit tests covering main outcome branches for the helper.

Reviewed changes

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

File Description
build-tools/packages/build-cli/src/test/library/latestVersions.test.ts Adds unit tests for the new helper’s decision outcomes.
build-tools/packages/build-cli/src/library/latestVersions.ts Introduces shared helper and result type for “latest in major” evaluation.
build-tools/packages/build-cli/src/commands/vnext/check/latestVersions.ts Replaces inline logic with a call to isLatestInMajor.
build-tools/packages/build-cli/src/commands/check/latestVersions.ts Replaces inline logic with a call to isLatestInMajor.

inputVersion: string,
): LatestVersionCheckResult {
const stableVersions = allVersions
.filter((v) => !isInternalVersionScheme(v))
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

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

isLatestInMajor is documented as checking the latest stable version and says the input list may include prerelease versions, but the implementation only filters out Fluid internal-version-scheme values. Non-internal semver prereleases (e.g. 1.2.3-beta.1) will be treated as stable candidates, which can cause incorrect "latest" results if such tags exist. Either filter out semver.prerelease(v) as well, or update the docstring/parameter description to match the actual behavior.

Suggested change
.filter((v) => !isInternalVersionScheme(v))
.filter((v) => !isInternalVersionScheme(v) && semver.prerelease(v) === null)

Copilot uses AI. Check for mistakes.
});

it("filters out internal/prerelease versions", () => {
const result = isLatestInMajor(["1.0.0", "2.0.0-internal.1.0.0", "1.2.3"], "1.2.3");
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

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

The test "filters out internal/prerelease versions" only includes an internal-version-scheme example and does not include a non-internal semver prerelease (e.g. 1.2.4-beta.1). As written, it won't catch regressions around prerelease filtering; either add a prerelease case or rename the test to reflect what it actually asserts.

Suggested change
const result = isLatestInMajor(["1.0.0", "2.0.0-internal.1.0.0", "1.2.3"], "1.2.3");
const result = isLatestInMajor(["1.0.0", "2.0.0-internal.1.0.0", "1.2.3", "1.2.4-beta.1"], "1.2.3");

Copilot uses AI. Check for mistakes.
@dhr-verma dhr-verma merged commit c9192c0 into microsoft:main Mar 2, 2026
29 checks passed
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.

Duplicate code: latestVersions stable-major deployment logic duplicated in build-cli check commands

3 participants