Skip to content

Commit 8430287

Browse files
committed
[Packaging] az upgrade: Detect correct cask token for preview vs production
During the preview phase (Plan B), the cask is distributed as `azure-cli-preview` via a custom tap, while post-migration it becomes `azure-cli` in homebrew-cask. The `az upgrade` command now checks which cask token is installed and upgrades accordingly.
1 parent 07bd485 commit 8430287

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

  • src/azure-cli/azure/cli/command_modules/util

src/azure-cli/azure/cli/command_modules/util/custom.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,17 @@ def upgrade_version(cmd, update_all=None, yes=None, allow_preview=None): # pyli
132132
exit_code = subprocess.call(update_cmd)
133133
elif installer == 'HOMEBREW_CASK':
134134
logger.debug("Update homebrew cask")
135+
# Determine cask token: 'azure-cli-preview' (custom tap) or 'azure-cli' (homebrew-cask)
136+
cask_token = 'azure-cli'
137+
try:
138+
if subprocess.call(['brew', 'list', '--cask', 'azure-cli-preview'],
139+
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) == 0:
140+
cask_token = 'azure-cli-preview'
141+
except Exception: # pylint: disable=broad-except
142+
pass
135143
exit_code = subprocess.call(['brew', 'update'])
136144
if exit_code == 0:
137-
update_cmd = ['brew', 'upgrade', '--cask', 'azure-cli']
145+
update_cmd = ['brew', 'upgrade', '--cask', cask_token]
138146
logger.debug("Update azure cli with '%s'", " ".join(update_cmd))
139147
exit_code = subprocess.call(update_cmd)
140148
elif installer == 'PIP':

0 commit comments

Comments
 (0)