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