feat: Add build-time policy to disable self-update in packaged builds#675
feat: Add build-time policy to disable self-update in packaged builds#675melund wants to merge 4 commits intomicrosoft:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a build-time policy hook that allows packaged/distribution builds (brew/pixi/conda, etc.) to disable apm update and provide distributor-specific update guidance, while also adjusting the startup update notification behavior.
Changes:
- Introduces
src/apm_cli/update_policy.pywith patchable constants and helper accessors for self-update enablement and messaging. - Wires the policy into
apm update(early exit with guidance) and into_check_and_notify_updates()(skip update notifications when disabled). - Updates CLI reference docs and adds unit tests covering the disabled-policy flows.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/test_update_command.py | Adds a unit test ensuring apm update exits successfully and skips network/installer when policy disables self-update. |
| tests/unit/test_command_helpers.py | Adds a unit test ensuring startup update checks are skipped when self-update is disabled. |
| src/apm_cli/update_policy.py | New centralized module for build-time self-update policy + guidance message helpers. |
| src/apm_cli/commands/update.py | Enforces the policy in the update command by short-circuiting when disabled. |
| src/apm_cli/commands/_helpers.py | Skips update notifications when disabled; uses a helper to render the update hint consistently. |
| docs/src/content/docs/reference/cli-commands.md | Documents distribution-managed update behavior and the skipped startup notification behavior. |
|
@microsoft-github-policy-service agree |
sergio-sisternes-epam
left a comment
There was a problem hiding this comment.
Thanks for the contribution @melund -- great use case for conda-forge and other distribution-managed builds. The overall design is clean and well-scoped.
One change requested: the bool() coercion on SELF_UPDATE_ENABLED can silently defeat the policy when packagers use string substitution during builds. See the inline comment for a one-line fix using identity check (is True) that fails safe.
|
Do you want me to rebase, or can you just squash-merge the PR? |
Description
Add a build-time self-update policy so package-manager distributions of apm (for example pixi or brew) can disable
apm updateand show a custom guidance message instead.This is useful for for example the conda-forge packaged version of apm, which I have added here:
https://github.com/conda-forge/apm-cli-feedstock
In such cases
apmshould not update it self.The PR creates a
update_policymodule which package mangers can patch. It wires the policy into theupdatecommand and startup update notification path.The PR also updates docs to explain distribution-managed update behavior. It also adds unit tests for the new disabled-policy flow.
Type of change
Testing