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

fix(autoupdate): Fix file hash extraction #5295

Merged
merged 2 commits into from
Dec 18, 2022
Merged

fix(autoupdate): Fix file hash extraction #5295

merged 2 commits into from
Dec 18, 2022

Conversation

niheaven
Copy link
Member

@niheaven niheaven commented Dec 17, 2022

Description

Fix file hash extraction:

  • From ([a-fA-F0-9]{32,128})[\x20\t]+.*$basename(?:[\x20\t]+\d+)?
  • To ([a-fA-F0-9]{32,128})[\x20\t]+.*$basename(?:\s|$)|$basename[\x20\t]+.*?([a-fA-F0-9]{32,128})

And format the file.

Motivation and Context

If checksum file has multiple hashes and filenames, the original regex may be failed 'cos there're many filenames that have same prefix, e.g., aaa.exe and aaa.exe.bbb. In such case, old one may not get the correct hash.

By ending with \s|$, the regex will use $basename only to find hash.

Also support hash format as aaa.exe <hash>.

How Has This Been Tested?

goreleaser ```json { "version": "1.13.1", "description": "Release automation tool for Go projects.", "homepage": "https://goreleaser.com", "license": "MIT", "architecture": { "64bit": { "url": "https://github.com/goreleaser/goreleaser/releases/download/v1.13.1/goreleaser_Windows_x86_64.zip", "hash": "c3880be7597a5f9478cb8bf2ba291b8b1ff749191f373de886cbc4583c5a8c51" }, "32bit": { "url": "https://github.com/goreleaser/goreleaser/releases/download/v1.13.1/goreleaser_Windows_i386.zip", "hash": "f54271982cde3f8e8852e35527bb5d5bdd0c6e2f9cbdbaabd091d3f87a768fc8" } }, "bin": "goreleaser.exe", "checkver": { "github": "https://github.com/goreleaser/goreleaser/" }, "autoupdate": { "architecture": { "64bit": { "url": "https://github.com/goreleaser/goreleaser/releases/download/v$version/goreleaser_Windows_x86_64.zip" }, "32bit": { "url": "https://github.com/goreleaser/goreleaser/releases/download/v$version/goreleaser_Windows_i386.zip" } }, "hash": { "url": "$baseurl/checksums.txt" } } } ```

Checklist:

  • I have read the Contributing Guide.
  • I have ensured that I am targeting the develop branch.
  • I have updated the documentation accordingly.
  • I have updated the tests accordingly.
  • I have added an entry in the CHANGELOG.

@niheaven niheaven merged commit 52f9ce3 into develop Dec 18, 2022
@niheaven niheaven deleted the fix-hash-check branch December 18, 2022 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants