krz/hutch

an ios client for sourcehut

clone: git clone https://gitbay.org/krz/hutch.git

v2.8.1: codex-fix-refs-type-conflict.md · raw

 1# Fix: Conflicting `[Reference]` vs `[ReferenceDetail]` in RepositorySettingsView
 2
 3## Background
 4
 5`RepositoryDetailViewModel.branches` was recently changed from `[Reference]` to
 6`[ReferenceDetail]` to support displaying commit dates in the Refs tab.
 7`ReferenceDetail` has the same `name: String` and `target: String?` fields as
 8`Reference`, plus an additional `date: Date?`.
 9
10`RepositorySettingsView` and `RepositorySettingsViewModel` still declare their
11`branches` parameter as `[Reference]`, causing this compiler error:
12
13```
14RepositoryDetailView.swift:56:51
15Conflicting arguments to generic parameter 'T' ('[ReferenceDetail]' vs. '[Reference]')
16```
17
18The settings view model only uses `branches` for the HEAD branch picker
19(`selectedHeadReferenceForSave()` accesses `$0.name`). No mapping back to
20`Reference` is needed — just update the type throughout the settings layer.
21
22---
23
24## Changes Required
25
26### 1. `Hutch/Views/Repositories/RepositorySettingsViewModel.swift`
27
28**Change the stored property type:**
29
30Find:
31```swift
32var branches: [Reference]
33```
34
35Replace with:
36```swift
37var branches: [ReferenceDetail]
38```
39
40**Change the `init` parameter type:**
41
42Find:
43```swift
44init(
45    repository: RepositorySummary,
46    branches: [Reference],
47    client: SRHTClient
48) {
49```
50
51Replace with:
52```swift
53init(
54    repository: RepositorySummary,
55    branches: [ReferenceDetail],
56    client: SRHTClient
57) {
58```
59
60### 2. `Hutch/Views/Repositories/RepositorySettingsView.swift`
61
62**Change the stored property type:**
63
64Find:
65```swift
66let branches: [Reference]
67```
68
69Replace with:
70```swift
71let branches: [ReferenceDetail]
72```
73
74---
75
76## No Other Changes
77
78- Do not modify `Reference` or `ReferenceDetail` in `Git.swift`.
79- Do not modify `RepositoryDetailView.swift` — the call site is already correct.
80- Do not modify `ReferencesListView.swift` or `RepositoryDetailViewModel.swift`.
81- `selectedHeadReferenceForSave()` in the settings view model accesses only
82  `$0.name` on each branch, which exists on `ReferenceDetail` — no logic
83  changes are needed.
84
85## Verification
86
87Build the project. The compiler error at `RepositoryDetailView.swift:56` should
88be gone. Confirm the repository settings sheet still opens and the HEAD branch
89picker populates correctly.