fix: resolve set() shadowing and sparse checkout ref issues#184
Merged
danielmeppiel merged 2 commits intomicrosoft:mainfrom Mar 6, 2026
Merged
Conversation
- 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
Contributor
There was a problem hiding this comment.
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 Clicksetcommand handler. - Ensure sparse checkout always fetches an explicit ref (defaulting to
HEAD) before checking outFETCH_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
approved these changes
Mar 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes two bugs reported in issue #179:
Bug 1: set() builtin shadowed by Click command
src/apm_cli/cli.pyset(_pre_download_results.keys())invokes Click's config set command instead of Python's builtinset()because@config.commanddecorator definesdef set(key, value)which overwrites theset = builtins.setalias.builtins.set(_pre_download_results.keys())explicitly.Bug 2: sparse checkout fetches wrong ref
src/apm_cli/deps/github_downloader.pygit fetch origin --depth=1fetches all branch tips and FETCH_HEAD points to the wrong commit, causing the expected subdirectory to be missing after checkout.Changes
cli.py: Changedset(...)tobuiltins.set(...)(line 1844)github_downloader.py: Changed conditional ref append to always pass ref (default to 'HEAD') (line 1076)Testing
python3 -m py_compile)Fixes #179