Skip to content

Do not show available updates with version if updater.enable_notification=false #2055

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Feb 1, 2023

Conversation

MatteoPologruto
Copy link
Contributor

Please check if the PR fulfills these requirements

See how to contribute

  • The PR has no duplicates (please search among the Pull Requests
    before creating one)
  • The PR follows
    our contributing guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • UPGRADING.md has been updated with a migration guide (for breaking changes)

What kind of change does this PR introduce?

Code enhancement

What is the current behavior?

The command arduino-cli version always shows if there is an available update, even if updater.enable_notification is set to false.

What is the new behavior?

arduino-cli version no longer ignores the flag updater.enable_notification.

Does this PR introduce a breaking change, and is titled accordingly?

No.

Other information

To test this change, I manually modified the ldflags to build an outdated version of the CLI, then set updater.enable_notification to false.

PS C:\Users\m.pologruto\Desktop\Arduino\arduino-cli> .\arduino-cli config dump                                 
board_manager:
  additional_urls: []
daemon:
  port: "50051"
directories:
  data: C:\Users\m.pologruto\AppData\Local\Arduino15
  downloads: C:\Users\m.pologruto\AppData\Local\Arduino15\staging
  user: C:\Users\m.pologruto\Documents\Arduino
library:
  enable_unsafe_install: true
logging:
  file: ""
  format: text
  level: info
metrics:
  addr: :9090
  enabled: true
output:
  no_color: false
sketch:
  always_export_binaries: false
updater:
  enable_notification: false

PS C:\Users\m.pologruto\Desktop\Arduino\arduino-cli> .\arduino-cli version                                     
arduino-cli.exe  Version: 0.17.0 Commit: 60a8aa96 Date: 2023-01-31T11:44:05Z

If updater.enable_notification is set to true, the command behaves normally. I must point out that, as of now, arduino-cli version shows if any updates are available only once every 24h, since CheckForUpdate() relies also on this check:

if inventory.Store.IsSet("updater.last_check_time") && time.Since(inventory.Store.GetTime("updater.last_check_time")).Hours() < 24 {
		// Checked less than 24 hours ago, let's wait
		return false
	}

Here is an example:

PS C:\Users\m.pologruto\Desktop\Arduino\arduino-cli> .\arduino-cli config set updater.enable_notification true 
PS C:\Users\m.pologruto\Desktop\Arduino\arduino-cli> .\arduino-cli version
arduino-cli.exe  Version: 0.17.0 Commit: 60a8aa96 Date: 2023-01-31T11:44:05Z


A new release of Arduino CLI is available: 0.17.0 → 0.29.0
https://arduino.github.io/arduino-cli/latest/installation/#latest-packages
PS C:\Users\m.pologruto\Desktop\Arduino\arduino-cli> .\arduino-cli version
arduino-cli.exe  Version: 0.17.0 Commit: 60a8aa96 Date: 2023-01-31T11:51:11Z

@MatteoPologruto MatteoPologruto added type: enhancement Proposed improvement topic: code Related to content of the project itself topic: CLI Related to the command line interface labels Jan 31, 2023
@MatteoPologruto MatteoPologruto self-assigned this Jan 31, 2023
@codecov
Copy link

codecov bot commented Jan 31, 2023

Codecov Report

Base: 36.64% // Head: 36.72% // Increases project coverage by +0.07% 🎉

Coverage data is based on head (507e444) compared to base (60a8aa9).
Patch coverage: 0.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2055      +/-   ##
==========================================
+ Coverage   36.64%   36.72%   +0.07%     
==========================================
  Files         228      228              
  Lines       19396    19396              
==========================================
+ Hits         7108     7123      +15     
+ Misses      11457    11446      -11     
+ Partials      831      827       -4     
Flag Coverage Δ
unit 36.72% <0.00%> (+0.07%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
internal/cli/version/version.go 0.00% <0.00%> (ø)
arduino/cores/packagemanager/package_manager.go 68.19% <0.00%> (+0.72%) ⬆️
arduino/monitor/monitor.go 47.36% <0.00%> (+6.31%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@cmaglie cmaglie merged commit 3ac8320 into arduino:master Feb 1, 2023
@MatteoPologruto MatteoPologruto deleted the disable-version-updater branch February 1, 2023 14:39
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
topic: CLI Related to the command line interface topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

updater.enable_notification=false should disable version checking even in version command
2 participants