Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/upgrade-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
run: |
# gh aw upgrade calls upgradeExtensionIfOutdated which:
# 1. Detects current ($PREVIOUS) < latest ($LATEST)
# 2. Runs `gh extension upgrade github/gh-aw`
# 2. Runs `gh extension upgrade github/gh-aw --force`
# 3. On Windows: binary is in use → rename+retry workaround is triggered
# 4. Re-launches the freshly installed binary with --skip-extension-upgrade
# --pre-releases ensures the upgrade check considers prereleases.
Expand Down
13 changes: 11 additions & 2 deletions pkg/cli/update_extension_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func upgradeExtensionIfOutdated(verbose bool, includePrereleases bool) (bool, st
// rename+retry path succeeds and the user is not shown a confusing failure.
var firstAttemptBuf bytes.Buffer
firstAttemptOut := firstAttemptWriter(os.Stderr, &firstAttemptBuf)
firstCmd := exec.Command("gh", "extension", "upgrade", "github/gh-aw")
firstCmd := exec.Command("gh", extensionUpgradeArgs()...)
firstCmd.Stdout = firstAttemptOut
firstCmd.Stderr = firstAttemptOut
firstErr := firstCmd.Run()
Expand Down Expand Up @@ -146,7 +146,7 @@ func upgradeExtensionIfOutdated(verbose bool, includePrereleases bool) (bool, st
}
}

retryCmd := exec.Command("gh", "extension", "upgrade", "github/gh-aw")
retryCmd := exec.Command("gh", extensionUpgradeArgs()...)
retryCmd.Stdout = os.Stderr
retryCmd.Stderr = os.Stderr
if retryErr := retryCmd.Run(); retryErr != nil {
Expand Down Expand Up @@ -255,3 +255,12 @@ func isWindowsLockError(output string, err error) bool {
}
return false
}

// extensionUpgradeArgs returns the gh extension upgrade invocation used by
// self-upgrade checks.
//
// --force is required so pinned installs (e.g. `gh extension install ... --pin`)
// can be upgraded in-place.
func extensionUpgradeArgs() []string {
return []string{"extension", "upgrade", "github/gh-aw", "--force"}
Comment on lines +262 to +265
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

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

Since --force is required for pinned installs (as noted here), the Windows manual-upgrade guidance printed on lock errors (gh extension upgrade gh-aw) will still fail for pinned installs. Please update that user-facing command to include --force (and ideally keep the suggested command consistent with extensionUpgradeArgs).

Copilot uses AI. Check for mistakes.
}
5 changes: 5 additions & 0 deletions pkg/cli/update_extension_check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,3 +224,8 @@ func TestIsWindowsLockError(t *testing.T) {
})
}
}

func TestExtensionUpgradeArgs(t *testing.T) {
args := extensionUpgradeArgs()
assert.Equal(t, []string{"extension", "upgrade", "github/gh-aw", "--force"}, args, "upgrade command must force upgrades for pinned extensions")
}
Loading