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 issue which saw versions resolved twice #1064

Merged
merged 1 commit into from
May 11, 2024

Conversation

rgee0
Copy link
Contributor

@rgee0 rgee0 commented May 11, 2024

Description

The version of a tool was being looked up twice - once prior to downloading and again post downloading. This was because GetUrl was being reached twice, initially to determine the download url and then again to determine whether the download was an archive.

This change introduces a new function which takes the download url and uses that to determine whether its an archive. This removes the additional round trip and the associated output. The new function is also covered by an additional test.

Motivation and Context

How Has This Been Tested?

Functional before and after:

➜  arkade git:(isArchive) arkade get popeye                                        
Downloading: popeye
2024/05/11 07:49:17 Looking up version for popeye
2024/05/11 07:49:17 Found: v0.21.3
Downloading: https://github.com/derailed/popeye/releases/download/v0.21.3/popeye_Darwin_amd64.tar.gz
17.64 MiB / 17.64 MiB [---------------------------------------------------------------------------------------------] 100.00%
/var/folders/3w/tv6429v51kl_61rd1fr25sgm0000gq/T/arkade-2877672800/popeye_Darwin_amd64.tar.gz written.
2024/05/11 07:49:20 Looking up version for popeye
2024/05/11 07:49:20 Found: v0.21.3
2024/05/11 07:49:20 Extracted: /var/folders/3w/tv6429v51kl_61rd1fr25sgm0000gq/T/arkade-2877672800/popeye
2024/05/11 07:49:20 Copying /var/folders/3w/tv6429v51kl_61rd1fr25sgm0000gq/T/arkade-2877672800/popeye to /Users/rgee0/.arkade/bin/popeye

Wrote: /Users/rgee0/.arkade/bin/popeye (60.24MB)

➜  arkade git:(isArchive) ./arkade get popeye                                        
Downloading: popeye
2024/05/11 07:49:26 Looking up version for popeye
2024/05/11 07:49:26 Found: v0.21.3
Downloading: https://github.com/derailed/popeye/releases/download/v0.21.3/popeye_Darwin_amd64.tar.gz
17.64 MiB / 17.64 MiB [---------------------------------------------------------------------------------------------] 100.00%
/var/folders/3w/tv6429v51kl_61rd1fr25sgm0000gq/T/arkade-2167759258/popeye_Darwin_amd64.tar.gz written.
2024/05/11 07:49:29 Extracted: /var/folders/3w/tv6429v51kl_61rd1fr25sgm0000gq/T/arkade-2167759258/popeye
2024/05/11 07:49:29 Copying /var/folders/3w/tv6429v51kl_61rd1fr25sgm0000gq/T/arkade-2167759258/popeye to /Users/rgee0/.arkade/bin/popeye

Wrote: /Users/rgee0/.arkade/bin/popeye (60.24MB)

make e2e

➜  arkade git:(isArchive) make e2e 
...
PASS
coverage: 60.2% of statements
ok      github.com/alexellis/arkade/pkg/get     16.141s coverage: 60.2% of statements

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)

Documentation

  • I have updated the list of tools in README.md if (required) with ./arkade get --format markdown
  • I have updated the list of apps in README.md if (required) with ./arkade install --help

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I've read the CONTRIBUTION guide
  • I have signed-off my commits with git commit -s
  • I have tested this on arm, or have added code to prevent deployment

The version of a tool was being looked up twice - once prior to downloading
and again post downloading.  This was because GetUrl was being reached twice,
initially to determine the download url and then again to determine whether
the download was an archive.

This change introduces a new function which takes the download url and
uses that to determine whether its an archive.  This removes the additional
round trip and the associated output.  The new function is also covered by
an additional test.

Signed-off-by: Richard Gee <[email protected]>
Copy link
Owner

@alexellis alexellis left a comment

Choose a reason for hiding this comment

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

👌 nice work on the issue and the fix

@alexellis alexellis merged commit 9be14a2 into alexellis:master May 11, 2024
2 checks passed
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.

Version appears to be looked up twice
2 participants