Skip to content

fix: resolve set() shadowing and sparse checkout ref issues#184

Merged
danielmeppiel merged 2 commits intomicrosoft:mainfrom
Jah-yee:fix/cli-set-builtin-sparse-checkout
Mar 6, 2026
Merged

fix: resolve set() shadowing and sparse checkout ref issues#184
danielmeppiel merged 2 commits intomicrosoft:mainfrom
Jah-yee:fix/cli-set-builtin-sparse-checkout

Conversation

@Jah-yee
Copy link
Contributor

@Jah-yee Jah-yee commented Mar 6, 2026

Summary

This PR fixes two bugs reported in issue #179:

Bug 1: set() builtin shadowed by Click command

  • File: src/apm_cli/cli.py
  • Problem: set(_pre_download_results.keys()) invokes Click's config set command instead of Python's builtin set() because @config.command decorator defines def set(key, value) which overwrites the set = builtins.set alias.
  • Fix: Use builtins.set(_pre_download_results.keys()) explicitly.

Bug 2: sparse checkout fetches wrong ref

  • File: src/apm_cli/deps/github_downloader.py
  • Problem: When no ref is provided, git fetch origin --depth=1 fetches all branch tips and FETCH_HEAD points to the wrong commit, causing the expected subdirectory to be missing after checkout.
  • Fix: Always pass an explicit ref to git fetch - defaults to HEAD if not provided.

Changes

  • cli.py: Changed set(...) to builtins.set(...) (line 1844)
  • github_downloader.py: Changed conditional ref append to always pass ref (default to 'HEAD') (line 1076)

Testing

  • Syntax validation passed (python3 -m py_compile)
  • These fixes address the Release Validation CI job failure

Fixes #179

- cli.py: Use builtins.set() instead of set() to avoid Click command shadowing
- github_downloader.py: Always pass explicit ref to git fetch (default to HEAD)

Fixes microsoft#179
Copy link
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

Fixes two reported regressions: set() being shadowed by a Click command in the CLI, and sparse checkout occasionally checking out the wrong commit by fetching an ambiguous ref.

Changes:

  • Use builtins.set(...) explicitly to avoid calling the Click set command handler.
  • Ensure sparse checkout always fetches an explicit ref (defaulting to HEAD) before checking out FETCH_HEAD.

Reviewed changes

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

File Description
src/apm_cli/deps/github_downloader.py Adjusts git fetch invocation to always include a ref for sparse checkout flows.
src/apm_cli/cli.py Avoids set() shadowing by explicitly referencing builtins.set().

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@danielmeppiel danielmeppiel merged commit e9d5ba1 into microsoft:main Mar 6, 2026
5 of 6 checks passed
@Jah-yee Jah-yee deleted the fix/cli-set-builtin-sparse-checkout branch March 6, 2026 10:56
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.

[BUG] set() builtin shadowed by Click command + sparse checkout fetches wrong ref

3 participants