Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(tortoisegit) Skip install when the packaged version is already installed #2161

Conversation

brogers5
Copy link
Contributor

Description

This changeset implements an install-time version-check for tortoisegit, intended to allow package installs/upgrades to succeed when the packaged software version is already installed. This should gracefully handle both new package installs for pre-existing installations, as well as software upgrades that happen outside of Chocolatey.

Motivation and Context

Fixes #2159.

I recently found myself in this situation when TortoiseGit itself prompted me to update to v2.14.0.0. Seeing an update prompt in Chocolatey-managed software normally triggers me running choco outdated --ignore-pinned to check if an updated package is available from the Community Repository.

As no such package was available at the time, I opted to upgrade the software manually, with the understanding that I'd pick up an updated package later when it became available. When an updated package for TortoiseGit became available. I tried to upgrade and ran into the documented issue.

Implementing this for behavior consistency with some other community packages (e.g. brave, firefox, flightgear, googlechrome, inkscape, opera, thunderbird), as well as to prevent the need for workarounds (e.g. using the --skip-powershell switch, waiting for the next package release, etc.) to get the software and package versions synchronized.

How Has this Been Tested?

Environments

Dev

  • OS Build: Windows 11 Pro v10.0.22621.0 (64-bit)
  • PowerShell version: 7.3.3
  • Chocolatey version: 1.3.0

Chocolatey Test Environment

  • Vagrant Box Version: 3.0.0
  • VM Provider: Virtualbox (although practically Hyper-V, since I manually converted the resulting virtual disk)
  • OS Build: Windows Server 2019 Datacenter v10.0.17763.0 (64-bit)
  • PowerShell version: 5.1.17763.3770
  • Chocolatey version: 1.3.0

Steps

Create a Test Package

  1. Revert tortoisegit.nuspec to fa29f72.
  2. Manually change newly introduced $softwareVersion variable in tools\chocolateyInstall.ps1 to '2.13.0.1'.
  3. Executed .\update_all.ps1 -Name tortoisegit -ForcedPackages tortoisegit to download software installers, test update.ps1 changes, and create a test package based on v2.14.0.0.

Clean Install Test

Note
TortoiseGit (both the package and software) is assumed to be currently uninstalled.

  1. Install the test package version (i.e. choco install tortoisegit --source="'.;https://community.chocolatey.org/api/v2/'" [to prioritize local packages while sourcing dependencies from the Community Repository]).
  2. Confirm software and package install succeeds without errors.

Existing Install Test

  1. Uninstall the existing package (i.e. choco uninstall tortoisegit).
  2. Manually download and execute TortoiseGit v2.14.0.0's 64-bit installer.
  3. Reinstall the test package version (i.e. choco install tortoisegit --source="'.'").
  4. Confirm the package skips installing TortoiseGit, and the package install succeeds without errors.

Chocolatey-Managed Upgrade Test

  1. Downgrade to a previous version of TortoiseGit (e.g. choco install tortoisegit --version=2.13.0.1 --allow-downgrade).
  2. Upgrade to the test package version (i.e. choco upgrade tortoisegit --source="'.'").
  3. Confirm that both the software and package upgrade succeeds without errors.

Upgrade Catchup Test

  1. Downgrade to a previous version of TortoiseGit (e.g. choco install tortoisegit --version=2.13.0.1 --allow-downgrade).
  2. If not already installed, install the git.install package to gain access to TortoiseGit's Settings dialog (e.g. choco install git.install).
  3. In File Explorer/Desktop, right-click on a blank space, browse to and press the TortoiseGit > Settings context menu item.
  4. In TortoiseGit's Settings dialog, on the General page, in the TortoiseGit groupbox, press the Check now button.
  5. In the Check For Updates dialog, press the Download button.
  6. When the installer download completes, press the Install button.
  7. Manually step through the installer to completion.
  8. Upgrade to the test package version (i.e. choco upgrade tortoisegit --source="'.'").
  9. Confirm the package skips installing TortoiseGit, and the package upgrade succeeds without errors.

Forced Reinstallation Test

  1. Force reinstallation of the test package in non-silent mode (i.e. choco install tortoisegit --source="'.'" --force --not-silent.
  2. Confirm the installer is started without issues.
  3. Browse to the next page in the installer, confirm the user is prompted to Modify/Repair/Remove the current installation.
  4. To gracefully progress the "installation", select the Modify or Repair option. Step through the installer to completion.
  5. Confirm that both the software and package "installation" succeeds without errors.

Screenshot (if appropriate, usually isn't needed):

N/A

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Migrated package (a package has been migrated from another repository)

Checklist:

  • My code follows the code style of this repository.
  • My change requires a change to documentation (this usually means the notes in the description of a package).
  • I have updated the documentation accordingly (this usually means the notes in the description of a package).
  • I have updated the package description and it is less than 4000 characters.
  • All files are up to date with the latest Contributing Guidelines
  • The added/modified package passed install/uninstall in the chocolatey test environment.
  • The changes only affect a single package (not including meta package).

@AppVeyorBot
Copy link

✅ Package verification completed without issues. PR is now pending human review

AdmiringWorm
AdmiringWorm previously approved these changes Mar 23, 2023
Copy link
Member

@AdmiringWorm AdmiringWorm left a comment

Choose a reason for hiding this comment

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

LGTM, I'll make some additional changes to this PR to get it up to date with our latest (pending) guidelines and get rid of some legacy code before I merge it in.

AdmiringWorm
AdmiringWorm previously approved these changes Mar 23, 2023
@AppVeyorBot
Copy link

❌ Package verification failed, please review the Appveyor Logs and the provided Artifacts before requesting a human reviewer to take a look.

This commit updates the package and package update script
to make use of our latest recommendations by not using globbing
patterns when getting the initial installer.

Additionally, legacy code about the need to select the correct
architecture manually has been removed as this is for much older
versions of Chocolatey CLI than what we support.
@AdmiringWorm AdmiringWorm force-pushed the tortoisegit-skip-install-of-current-version branch from 61a7bbb to 03014a1 Compare March 23, 2023 17:59
@AppVeyorBot
Copy link

✅ Package verification completed without issues. PR is now pending human review

@AdmiringWorm AdmiringWorm merged commit 47bb1bb into chocolatey-community:master Mar 23, 2023
@AdmiringWorm
Copy link
Member

@brogers5 your changes have been merged, thanks for your contribution 👍

@brogers5 brogers5 deleted the tortoisegit-skip-install-of-current-version branch March 23, 2023 23:29
@Leif-W
Copy link

Leif-W commented Apr 6, 2023

Just curious, does this update fix the Brave issue below, where Chocolatey does two version checks, the first one is incorrect and stale, as Brave auto-updates can't be disabled, so it will 100% of the time update outside of Chocolatey under normal use-case of daily browser usage. However, a secondary version check is correct, but only AFTER the time, bandwidth, and disk space has been wasted on an unnecessary download. Ideally, there should be a single, accurate version check, and only download anything if it really is necessary. This scenario may effect other software packages, but this is the situation I encounter most frequently.

You have brave v1.49.132 installed. Version 1.50.114 is available based on your source(s).
Progress: Downloading brave 1.50.114... 100%

brave v1.50.114 [Approved]
brave package files upgrade completed. Performing other installation steps.
Checking already installed version...
WARNING: Skipping installation because version 1.50.114 is already installed.

@pauby
Copy link
Member

pauby commented Apr 6, 2023

This update is for the tortoisegit package @Leif-W

@TheCakeIsNaOH
Copy link
Member

@Leif-W the first line

You have brave v1.49.132 installed. Version 1.50.114 is available based on your source(s).

is letting you know that the brave package v1.49.132 is installed, and that the package v1.50.114 is available.

Then Chocolatey CLI downloads and unpacks/installs the files inside the package. Then the chocolateyInstall.ps1 in the brave package is run. The line

WARNING: Skipping installation because version 1.50.114 is already installed.
comes from the chocolateyInstall.ps1, and is from the script check the Brave software is already up to date.

One check is to update the package, the other check is the package checking if the software is up to date.

If you want to discuss futher, I would suggest the chat, https://ch0.co/community

@chocolatey-community chocolatey-community locked as resolved and limited conversation to collaborators Apr 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(tortoisegit) Package upgrade fails if software was previously upgraded outside of Chocolatey
6 participants