Skip to content

Record successful index updates and honor automatic update settings - #842

Merged
edriouk merged 6 commits into
mainfrom
updateCfg
Sep 15, 2026
Merged

edriouk merged 6 commits into
mainfrom
updateCfg

Conversation

@edriouk

@edriouk edriouk commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator

Fixes

Changes

  • Record the current date in update.cfg only after update-index succeeds, while preserving the Auto setting.
  • Handle scanner errors when reading update configuration.
  • Ignore local AI tooling files and directories.
  • Implemented the UpdateDaily behavior and CLI control.
  • Added UpdateDaily flag instead of Auto
  • Missing or malformed UpdateDaily defaults to true
  • Legacy Auto is preserved but no longer controls automatic updates.
  • Configuration changes and Date are written only after a successful explicit update.
  • Added coverage for legacy configs, disabled updates, malformed values, explicit true/false flags, and failed updates.

Risks / Limitations

  • If writing update.cfg fails after the index is updated, update-index returns an error even though the index update itself succeeded.
  • Update timestamps retain the existing day-level precision.

Checklist

  • 🤖 This change is covered by unit tests (if applicable).
  • 🤹 Manual testing has been performed (if necessary).
  • 🛡️ Security impacts have been considered (if relevant).
  • 📖 Documentation updates are complete (if required).
  • 🧠 Third-party dependencies and TPIP updated (if required).

Record successful explicit updates while preserving the Auto setting, and
skip stale automatic updates when Auto is disabled. Default malformed Auto
values to enabled for backward compatibility and leave config unchanged on
failed updates.

Ignore local AI tooling files.
@qltysh

qltysh Bot commented Sep 15, 2026

Copy link
Copy Markdown

Qlty


Coverage Impact

⬆️ Merging this pull request will increase total coverage on main by 0.5%.

Modified Files with Diff Coverage (2)

RatingFile% DiffUncovered Line #s
Coverage rating: D Coverage rating: D
cmd/installer/root.go87.5%1869-1870, 1904, 1908
Coverage rating: B Coverage rating: A
cmd/commands/update_index.go100.0%
Total88.9%
🤖 Increase coverage with AI coding...
In the `updateCfg` branch, add test coverage for this new code:

- `cmd/installer/root.go` -- Lines 1869-1870, 1904, and 1908

🚦 See full report on Qlty Cloud »

🛟 Help
  • Diff Coverage: Coverage for added or modified lines of code (excludes deleted files). Learn more.

  • Total Coverage: Coverage for the whole repository, calculated as the sum of all File Coverage. Learn more.

  • File Coverage: Covered Lines divided by Covered Lines plus Missed Lines. (Excludes non-executable lines including blank lines and comments.)

    • Indirect Changes: Changes to File Coverage for files that were not modified in this PR. Learn more.

@github-actions

github-actions Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Test Results

    4 files  ± 0     24 suites  ±0   1m 3s ⏱️ -6s
  817 tests +12    817 ✅ +12  0 💤 ±0  0 ❌ ±0 
3 251 runs  +48  3 251 ✅ +48  0 💤 ±0  0 ❌ ±0 

Results for commit 256a16c. ± Comparison against base commit cf5551b.

This pull request removes 1 and adds 13 tests. Note that renamed tests count towards both.
github.com/open-cmsis-pack/cpackget/cmd/commands ‑ TestUpdateIndexCmd/test_updating_index_with_insecure-skip-verify_flag
github.com/open-cmsis-pack/cpackget/cmd/commands ‑ TestUpdateIndexCmd/test_failed_index_update_returns_download_error
github.com/open-cmsis-pack/cpackget/cmd/commands ‑ TestUpdateIndexCmd/test_malformed_index_returns_read_error
github.com/open-cmsis-pack/cpackget/cmd/commands ‑ TestUpdateIndexRejectsMissingPackRoot
github.com/open-cmsis-pack/cpackget/cmd/installer ‑ TestRecordPublicIndexUpdate
github.com/open-cmsis-pack/cpackget/cmd/installer ‑ TestRecordPublicIndexUpdate/preserves_settings_and_records_current_date
github.com/open-cmsis-pack/cpackget/cmd/installer ‑ TestRecordPublicIndexUpdate/returns_write_error
github.com/open-cmsis-pack/cpackget/cmd/installer ‑ TestUpdatePublicIndexIfOnline/test_daily_update_disabled
github.com/open-cmsis-pack/cpackget/cmd/installer ‑ TestUpdatePublicIndexIfOnline/test_legacy_Auto_false_is_ignored
github.com/open-cmsis-pack/cpackget/cmd/installer ‑ TestUpdatePublicIndexIfOnline/test_malformed_daily_setting_defaults_to_enabled
github.com/open-cmsis-pack/cpackget/cmd/installer ‑ TestWriteUpdateCfg
…

♻️ This comment has been updated with latest results.

@brondani
brondani requested a lite review from Copilot September 15, 2026 09:37
@edriouk
edriouk marked this pull request as ready for review September 15, 2026 09:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Three moderate issues remain unresolved in configuration handling, pack initialization, and update-date durability.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

This PR adds UpdateDaily handling, records successful explicit index updates, and introduces update-index --daily.

Changes:

  • Supports legacy configuration while adding UpdateDaily.
  • Persists update dates after successful updates.
  • Adds CLI and test coverage.
  • Ignores local AI tooling files.
File summaries
File Summary
cmd/installer/update_cfg_internal_test.go Tests configuration helpers.
cmd/installer/root.go Implements configuration and automatic update behavior; unresolved preservation and durability issues remain.
cmd/installer/root_test.go Tests automatic update scenarios.
cmd/commands/update_index.go Adds CLI control and date recording; configuration-only updates need proper initialization and unlocking.
cmd/commands/update_index_test.go Tests CLI update behavior.
cmd/commands/update_index_internal_test.go Tests command validation.
.gitignore Ignores local AI tooling files.
Review details

Suppressed comments (2)

cmd/commands/update_index.go:46

  • The --daily path only runs configureInstallerGlobalCmd, so it never initializes/unlocks the installer before writing .Web/update.cfg. For a pack root locked by LockPackRoot, a config-only invocation that needs to create update.cfg (and platforms that enforce directory read-only semantics for existing files) returns a permission error. Configure and unlock the pack root for this branch as well, then relock it on return.
		if cmd.Flags().Changed("daily") {
			if err := configureInstallerGlobalCmd(cmd, args); err != nil {
				return err
			}
			return installer.SetUpdateDaily(viper.GetString("pack-root"), updateIndexCmdFlags.daily)

cmd/installer/root.go:989

  • When the index file is missing, this branch ignores update.cfg and unconditionally rewrites both settings as true. A user who previously ran update-index --daily=false (or had legacy Auto=false) can therefore get an automatic bootstrap update that silently re-enables the setting the next time this helper runs. Preserve the existing configuration, or skip the automatic download when UpdateDaily is disabled, instead of resetting these flags.
		updateConf.Auto = true
		updateConf.UpdateDaily = true
  • Files reviewed: 6/7 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread cmd/installer/root.go Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Comment thread cmd/installer/root.go Fixed
… closed without error handling'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@edriouk
edriouk requested a review from jkrech September 15, 2026 09:57

@jkrech jkrech left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@edriouk
edriouk merged commit b89c787 into main Sep 15, 2026
23 checks passed
@edriouk
edriouk deleted the updateCfg branch September 15, 2026 13:10
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.

4 participants