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 bin update on prerelease-only github repos #87

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

sirlatrom
Copy link
Collaborator

@sirlatrom sirlatrom commented Mar 24, 2021

Relates to #86.
Fixes #84.

A future PR could add a (per-binary?) option to offer the latest prerelease if newer than latest release.

@sirlatrom sirlatrom added the bug Something isn't working label Mar 24, 2021
@sirlatrom sirlatrom requested a review from breml March 24, 2021 22:41
@sirlatrom sirlatrom self-assigned this Mar 24, 2021
@marcosnils
Copy link
Owner

If we're doing this, why not going all the way and letting bin handle pre-releases on install as well? I guess we need more discussion on #84 before merging this. The first thing that I would have implemented is making bin update not to fail, not to fetch the latest pre-release.

Thoughts?

@sirlatrom
Copy link
Collaborator Author

If we're doing this, why not going all the way and letting bin handle pre-releases on install as well?

That sounds reasonable, I'll add that in a moment.

@marcosnils
Copy link
Owner

That sounds reasonable, I'll add that in a moment.

Do we want this though? I've added a comment in #86

@marcosnils
Copy link
Owner

LGTM. Would like to hear @breml's thoughts before merging

@@ -138,6 +138,9 @@ func getLatestVersion(b *config.Binary, p providers.Provider) (*updateInfo, erro
if err != nil {
return nil, fmt.Errorf("Error checking updates for %s, %w", b.Path, err)
}
if v == "" && u == "" {
Copy link
Collaborator

Choose a reason for hiding this comment

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

In which case is it possible, that we do not have an error but still v and u are empty?

While reviewing this code, it was not helpful, that the two variables are named v and u, because this does not tell me anything what I can expect to be in these variables. Also the signature of GetLatestVersion does not tell me more (just that I get 2 strings and an error as return value). Therefore I propose to use some more speaking variable names.

// Return original 404/StatusNotFound error from GetLatestRelease
return nil, err
}
return release, err
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would explicitly return nil for the error to make it obvious for the reader of the code, that this is the happy path.

return release, nil

}
}

// Return original 404/StatusNotFound error from GetLatestRelease
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this comment is misleading, because there error could be 404 but it could also be an other error.

if listErr != nil {
return nil, listErr
}
if len(releases) > 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Again, is it possible to not get an error and an empty list of releases? I would expect the API to return an 404 here as well, if there are no releases at all.

@marcosnils
Copy link
Owner

@sirlatrom by any chance do you have any bandwidth to rebase this?

Signed-off-by: Sune Keller <sune.keller+gitlab.com@gmail.com>
Signed-off-by: Sune Keller <sune.keller+gitlab.com@gmail.com>
@sirlatrom sirlatrom force-pushed the fix-github-prerelease-update branch from 0aa8b7e to e4042ee Compare April 26, 2023 15:51
@sirlatrom
Copy link
Collaborator Author

@sirlatrom by any chance do you have any bandwidth to rebase this?

Rebased on "master".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: bin is not able to locate releases on Github for bufbuild/buf
3 participants