Skip to content

Suggest extracting prerelease tag resolution into a testable function for #1657#1661

Draft
Copilot wants to merge 1 commit into
mainfrom
copilot/suggest-solution-for-comment
Draft

Suggest extracting prerelease tag resolution into a testable function for #1657#1661
Copilot wants to merge 1 commit into
mainfrom
copilot/suggest-solution-for-comment

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 21, 2026

PR #1657 fixes the prerelease channel of copilot-cli by replacing git ls-remote | tail -1 with a sort -V pipeline. Review feedback asks that the pipeline be moved into a function and covered by a regression test.

This PR is advisory only — no repository changes were committed. Recommended changes for #1657:

  • Extract resolve_prerelease_version() in src/copilot-cli/install.sh that reads git ls-remote --tags output from stdin (for tests) or runs it against a repo URL passed as $1 (for production), then pipes through awk | sed | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9]+)?$' | sort -V | tail -n1.
  • Update the prerelease branch of install_using_github to call resolve_prerelease_version "https://github.com/github/copilot-cli".
  • Add test/copilot-cli/scenarios.json registering a resolve_prerelease_version scenario on mcr.microsoft.com/devcontainers/base:ubuntu.
  • Add test/copilot-cli/resolve_prerelease_version.sh that sources only the function (via awk '/^resolve_prerelease_version\(\)/,/^}$/' + eval, avoiding the installer's root check) and asserts ordering against a hermetic fixture covering the regression cases:
    • v1.0.45 > v1.0.9 (the original bug).
    • v1.0.45-10 > v1.0.45-2 (numeric prerelease suffix).
    • Peeled refs (^{}) and non-vX.Y.Z tags are filtered out.

Function snippet:

resolve_prerelease_version() {
    local repo_url="${1:-}"
    if [ -n "${repo_url}" ]; then
        git ls-remote --tags "${repo_url}"
    else
        cat
    fi \
      | awk '{print $2}' | sed 's|refs/tags/||' \
      | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9]+)?$' \
      | sort -V | tail -n1
}

Run locally with:

devcontainer features test -f copilot-cli \
  --skip-autogenerated --filter "resolve_prerelease_version" .

Stdin-driven design keeps the regression test hermetic (no network) and pins both the lexicographic-sort bug and the prerelease-suffix ordering against future regressions.

Original prompt

Check the comment here #1657 (comment) and suggest solution. Provide code snippets

Created from VS Code.

Copilot AI changed the title [WIP] Investigate suggested solution for code snippet issue Suggest extracting prerelease tag resolution into a testable function for #1657 May 21, 2026
Copilot AI requested a review from Kaniska244 May 21, 2026 11:32
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