Skip to content

feat: Add build-time policy to disable self-update in packaged builds#675

Open
melund wants to merge 4 commits intomicrosoft:mainfrom
melund:update-policy
Open

feat: Add build-time policy to disable self-update in packaged builds#675
melund wants to merge 4 commits intomicrosoft:mainfrom
melund:update-policy

Conversation

@melund
Copy link
Copy Markdown

@melund melund commented Apr 11, 2026

Description

Add a build-time self-update policy so package-manager distributions of apm (for example pixi or brew) can disable apm update and 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 apm should not update it self.

The PR creates a update_policy module which package mangers can patch. It wires the policy into the update command 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

  • Bug fix
  • New feature
  • Documentation
  • Maintenance / refactor

Testing

  • Tested locally
  • All existing tests pass
  • Added tests for new functionality (if applicable)

Copilot AI review requested due to automatic review settings April 11, 2026 14:51
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

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.py with 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.

@melund
Copy link
Copy Markdown
Author

melund commented Apr 11, 2026

@microsoft-github-policy-service agree

Copy link
Copy Markdown
Collaborator

@sergio-sisternes-epam sergio-sisternes-epam left a comment

Choose a reason for hiding this comment

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

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.

@melund
Copy link
Copy Markdown
Author

melund commented Apr 12, 2026

Do you want me to rebase, or can you just squash-merge the PR?

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.

3 participants