| 518 | } |
| 519 | |
| 520 | func (m *Manager) upgradeExtension(ext *Extension, force bool) error { |
| 521 | if ext.IsLocal() { |
| 522 | return localExtensionUpgradeError |
| 523 | } |
| 524 | if !force && ext.IsPinned() { |
| 525 | return pinnedExtensionUpgradeError |
| 526 | } |
| 527 | if !ext.UpdateAvailable() { |
| 528 | return upToDateError |
| 529 | } |
| 530 | var err error |
| 531 | if ext.IsBinary() { |
| 532 | err = m.upgradeBinExtension(ext) |
| 533 | } else { |
| 534 | // Check if git extension has changed to a binary extension |
| 535 | var isBin bool |
| 536 | repo, repoErr := repoFromPath(m.gitClient, filepath.Join(ext.Path(), "..")) |
| 537 | if repoErr == nil { |
| 538 | isBin, _ = isBinExtension(m.client, repo) |
| 539 | } |
| 540 | if isBin { |
| 541 | if err := m.Remove(ext.Name()); err != nil { |
| 542 | return fmt.Errorf("failed to migrate to new precompiled extension format: %w", err) |
| 543 | } |
| 544 | return m.installBin(repo, "") |
| 545 | } |
| 546 | err = m.upgradeGitExtension(ext, force) |
| 547 | } |
| 548 | return err |
| 549 | } |
| 550 | |
| 551 | func (m *Manager) upgradeGitExtension(ext *Extension, force bool) error { |
| 552 | if m.dryRunMode { |