Skip to content

fix: add subscribed_to_releases to local fields and fix hash loop#148

Merged
AmintaCCCP merged 1 commit into
mainfrom
fix/local-metadata-sync
May 18, 2026
Merged

fix: add subscribed_to_releases to local fields and fix hash loop#148
AmintaCCCP merged 1 commit into
mainfrom
fix/local-metadata-sync

Conversation

@AmintaCCCP
Copy link
Copy Markdown
Owner

@AmintaCCCP AmintaCCCP commented May 18, 2026

变更说明

基于 PR #147 (fix: 后端同步时保留仓库本地元数据) 的代码审查反馈,修复两个问题:

修复内容

  1. 补充 subscribed_to_releases 字段

    • Repository 类型中 subscribed_to_releases?: boolean 是用户本地操作的订阅标记
    • 原 PR 遗漏了该字段,导致后端同步时覆盖用户的 Release 订阅设置
    • 已加入 LOCAL_REPOSITORY_FIELDS
  2. 修复 hash 循环写问题

    • 原实现使用 quickHash(backendRepos) 作为 hash,但实际写入 store 的是合并后的数据
    • 如果后端不持久化本地字段,pull 回来的数据永远不含本地字段 → hash 始终不同 → 每次 poll 都触发 setRepositories → 不必要的写循环
    • 改为对合并后的数据计算 hash,避免多余操作

验证

  • TypeScript 编译通过
  • CI 构建通过(如需要可触发)

Summary by CodeRabbit

  • Bug Fixes
    • Fixed repository synchronization to properly preserve local subscription settings when merging data from the backend.

Review Change Stack

- Add subscribed_to_releases to LOCAL_REPOSITORY_FIELDS so backend sync
  doesn't overwrite local release subscription settings
- Compute hash from merged data instead of raw backend data to prevent
  unnecessary write loops when backend doesn't persist local fields
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 18, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c1f8485f-a8b8-48e9-888e-4e9f6d8e6d76

📥 Commits

Reviewing files that changed from the base of the PR and between 5d8e1e0 and ac810b9.

📒 Files selected for processing (2)
  • src/services/autoSync.ts
  • src/utils/repositoryMerge.ts

📝 Walkthrough

Walkthrough

The PR makes two coordinated changes to ensure local repository metadata survives backend synchronization. The merge utility now preserves the subscribed_to_releases field during merges, and the sync service recalculates its repository hash from the merged state to maintain consistency with preserved local data.

Changes

Repository Sync Metadata Preservation

Layer / File(s) Summary
Preserve subscribed_to_releases in merge utility
src/utils/repositoryMerge.ts
The subscribed_to_releases field is added to the LOCAL_REPOSITORY_FIELDS whitelist so its local value is copied onto the merged repository.
Use merged repository hash in sync service
src/services/autoSync.ts
In the non-bootstrap sync path, the repository hash tracked in _lastHash.repos is now recalculated from the merged state (quickHash(merged)) instead of the backend-derived hash, ensuring consistency with preserved local metadata.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • AmintaCCCP/GithubStarsManager#147: Updates syncFromBackend to merge backend and local repositories, establishing the foundation this PR refines with additional field preservation and hash recalculation.
  • AmintaCCCP/GithubStarsManager#142: Modifies syncFromBackend logic around repository merge and _lastHash.repos updates, directly overlapping with the sync service changes in this PR.
  • AmintaCCCP/GithubStarsManager#57: Implements release subscription toggling that depends on correct preservation of subscribed_to_releases metadata during sync and rollback operations.

Poem

🐰 A field preserved, a hash reborn,
Metadata survives the sync storm.
Merged and hashed in perfect step,
Local truth takes not one less rep! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes both key changes: preserving the subscribed_to_releases field in local metadata and fixing the hash computation logic to use merged data instead of backend data.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/local-metadata-sync

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@AmintaCCCP AmintaCCCP merged commit 4296dba into main May 18, 2026
5 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.

1 participant