microsoft / winget-create

The Windows Package Manager Manifest Creator command-line tool (aka wingetcreate)
MIT License
489 stars 84 forks source link

Get new RelativeFilePaths if previous do not exist #415

Closed mdanish-kh closed 1 year ago

mdanish-kh commented 1 year ago

This change makes it so we take the last portion of the RelativeFilePath i.e., the file name and search that file name in the new archive for a match. If it is a unique match, we get its RelativeFilePath and use it for the update.

Known limitation is that there are some cases where there may be more than one match in the archive (An example of this being DynamoRIO.DynamoRIO package). This is not handled in this PR and we print out an appropriate message to the user. I'll create an issue for it if this PR gets accepted.

The change to use the whole NestedInstallerFile object instead of previous RelativeFilePaths is so that I can replace this whole object in UpdateInstallerMetadata() and have it updated.

Test packages

Somes packages I found to test this PR with

wingetcreate update Smallstep.step -v 18.0 --urls "https://github.com/smallstep/cli/releases/download/v0.24.4/step_windows_0.24.4_amd64.zip" "https://github.com/smallstep/cli/releases/download/v0.24.4/step_windows_0.24.4_arm64.zip"
wingetcreate update Genymobile.scrcpy -v 18.0 --urls "https://github.com/Genymobile/scrcpy/releases/download/v1.25/scrcpy-win64-v1.25.zip" "https://github.com/Genymobile/scrcpy/releases/download/v1.25/scrcpy-win32-v1.25.zip"

Multiple matches for RelativeFilePaths (not handled in this PR)

wingetcreate update DynamoRIO.DynamoRIO --version 18.0 --urls "https://github.com/DynamoRIO/dynamorio/releases/download/cronbuild-9.93.19557/DynamoRIO-Windows-9.93.19557.zip"

Microsoft Reviewers: codeflow:open?pullrequest=https://github.com/microsoft/winget-create/pull/415&drop=dogfoodAlpha
mdanish-kh commented 1 year ago

The GitHub diffs are not correct after https://github.com/microsoft/winget-create/pull/415/commits/83973aa632218217c09ea7a330898a3a8e0083c0. I modified the UpdateSingleInstallerInteractively method but that method had both mixed line endings (CRLF and LF) because of which the diffs are messed up. If you check out the changes in Visual Studio, it'll show you the correct diffs.

If you like I can fix the line endings for UpdateCommand.cs and PackageParser.cs in a new commit as they are the two most high traffic files, though that'll mess the diffs up even more for this PR

ryfu-msft commented 1 year ago

/azp run

azure-pipelines[bot] commented 1 year ago
Azure Pipelines successfully started running 1 pipeline(s).
ryfu-msft commented 1 year ago

The GitHub diffs are not correct after 83973aa. I modified the UpdateSingleInstallerInteractively method but that method had both mixed line endings (CRLF and LF) because of which the diffs are messed up. If you check out the changes in Visual Studio, it'll show you the correct diffs.

If you like I can fix the line endings for UpdateCommand.cs and PackageParser.cs in a new commit as they are the two most high traffic files, though that'll mess the diffs up even more for this PR

If you can do this in a separate PR (after this gets checked in) that would be a huge help! 🙏 That way we can link the related issue to that PR when it gets checked in.

mdanish-kh commented 1 year ago

If you can do this in a separate PR (after this gets checked in) that would be a huge help! 🙏 That way we can link the related issue to that PR when it gets checked in.

Gotcha! Will do after this one. I was shying away from fixing the line endings since it'll mess up the git blame output but I guess fixing it has more value.

ryfu-msft commented 1 year ago

/azp run

azure-pipelines[bot] commented 1 year ago
Azure Pipelines successfully started running 1 pipeline(s).
ryfu-msft commented 1 year ago

/azp run

azure-pipelines[bot] commented 1 year ago
Azure Pipelines successfully started running 1 pipeline(s).