Skip to content

Notify new releases only once per day#2488

Merged
mislav merged 3 commits intocli:trunkfrom
cristiand391:new-release-notification
Dec 15, 2020
Merged

Notify new releases only once per day#2488
mislav merged 3 commits intocli:trunkfrom
cristiand391:new-release-notification

Conversation

@cristiand391
Copy link
Contributor

@cristiand391 cristiand391 commented Nov 26, 2020

Fix #2485

I've tested this locally with hardcoded values and works as expected.

gh will only notice a new release after the network check.
If state.yml doesn't exists(new users), CheckForUpdate() will continue in order to create the file.

@contourintegrals
Copy link
Contributor

contourintegrals commented Nov 26, 2020

As mentioned in #2485, I guess instead of hard-coding 24 hours(1 day), we could store a config key inside the gh config file. That would conform to the issue better (IMHO).

@cristiand391 cristiand391 marked this pull request as draft November 26, 2020 20:07
@cristiand391 cristiand391 marked this pull request as draft November 26, 2020 20:07
@cristiand391 cristiand391 marked this pull request as ready for review November 26, 2020 22:39
@cristiand391
Copy link
Contributor Author

@shrihanDev gh already stores the last time a network check has been perfomed in state.yml.
This PR makes it read that timestamp to avoid noticing a new release if said check was performed less than 24hs ago.

@contourintegrals
Copy link
Contributor

contourintegrals commented Nov 27, 2020

@cristiand391 Sorry for not being clear at first, but actually I meant that instead of 24 hours, we could let the user decide the interval. The user could set a config key that stores the time interval, and then gh should read the value of that config key and do apropos.

Sorry if I miss something again 😢

@cristiand391
Copy link
Contributor Author

@shrihanDev no need to apologize, sorry if I sounded rude 😅.
I went with 24hs because that's how frequently gh checks for update.

I can't see how a user would benefit from customizing it, but if more users ask for it then maybe the cli team will consider adding it.

@contourintegrals
Copy link
Contributor

@cristiand391 No probs! Let's wait for more votes to this customisation.

@mgabeler-lee-6rs
Copy link
Contributor

The one logical customization I can see is being able to disable the update checks in the config file, not just via env vars. I agree w/ @cristiand391 there doesn't seem to be much value in fine tuning the frequency of update checks as a user.

Otherwise I was about to put up a PR doing the same thing as this one based on @mislav's helpful pointer in #2485, when I saw this one was already here :)

@contourintegrals
Copy link
Contributor

contourintegrals commented Nov 29, 2020

So stupid of me! I was thinking that this PR adds the functionality to check for release builds in each repository, and notify once a day 🤦🏻‍♂️

Extremely sorry.

@contourintegrals
Copy link
Contributor

Now that I know what's going on, I guess it's pointless to customise the frequency of the new-release-checking.

@cristiand391 cristiand391 requested a review from samcoe November 30, 2020 20:50
@samcoe
Copy link
Contributor

samcoe commented Dec 1, 2020

Thank you for your contribution!

I've pushed a commit to simplify things. I wanted reduce the responsibilities of getLatestReleaseInfo and move the StateFile handling into CheckForUpdate. This made it easier to read and write the file only when necessary and IMO makes the logic easier to follow and reason about. It is now easy to see how if the StateFile shows that we checked for an update less than 24 hours ago we will short circuit the rest of the CheckForUpdate function.

@samcoe samcoe requested review from mislav and vilmibm December 1, 2020 17:31
@samcoe samcoe force-pushed the new-release-notification branch from f4b8254 to 3ee3d61 Compare December 2, 2020 02:10
Copy link
Contributor

@mislav mislav left a comment

Choose a reason for hiding this comment

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

Looks great! Thank you both 🚀

@mislav mislav force-pushed the new-release-notification branch from 3ee3d61 to 2843fff Compare December 15, 2020 15:10
@mislav mislav merged commit d81b292 into cli:trunk Dec 15, 2020
@ahmedhmn

This comment has been minimized.

1 similar comment
@ahmedhmn

This comment has been minimized.

@cristiand391 cristiand391 deleted the new-release-notification branch January 3, 2021 21:38
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.

Alerting on new release for every invocation is excessive

6 participants