Commit 4a2e02a
authored
[Repo Assist] fix(rust-guard): remove write-only owner-type cache and simplify get_issue_author_association (#4339)
🤖 *This is an automated pull request from Repo Assist.*
Closes #4329
## Root Cause
Two dead-code / duplication issues in
`guards/github-guard/rust-guard/src/labels/backend.rs`:
**Issue 1 — Write-only `repo_owner_type_cache`**
`set_cached_owner_is_org` (and the `repo_owner_type_cache` it writes to)
existed in anticipation of a `get_cached_owner_is_org` reader that was
never wired up. Every `is_repo_private_with_callback` call acquired a
Mutex lock and inserted into a `HashMap` that grew without bound and was
never consulted. Classic incomplete-feature footgun.
**Issue 2 — `get_issue_author_association_with_callback` is a strict
subset of `get_issue_author_info_with_callback`**
Both functions made the same `issue_read` backend call, parsed the same
args, allocated the same buffer size, and extracted `author_association`
via the identical two-field fallback. The only difference was that the
`info` variant also extracted `author_login`. This 35-line duplication
meant any future change to the `issue_read` call shape had to be applied
in two places.
## Fix
1. **Remove** `repo_owner_type_cache`, `set_cached_owner_is_org`, and
the call site inside `is_repo_private_with_callback`. The debug log line
is retained; only the cache write is dropped.
2. **Replace** the 35-line body of
`get_issue_author_association_with_callback` with a one-liner that
delegates to `get_issue_author_info_with_callback`:
```rust
get_issue_author_info_with_callback(callback, owner, repo, issue_number)
.and_then(|info| info.author_association)
```
## Trade-offs
- Purely mechanical changes; zero semantic change.
- Removes 41 lines net. The `get_issue_author_association` public API is
unchanged.
## Test Status
- ✅ `cargo build` — compiles without warnings
- ✅ `cargo test` — **322 / 322 tests pass**
- 1 file changed
Lines changed: 3 additions & 41 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | 22 | | |
28 | 23 | | |
29 | 24 | | |
| |||
60 | 55 | | |
61 | 56 | | |
62 | 57 | | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | 58 | | |
70 | 59 | | |
71 | 60 | | |
| |||
218 | 207 | | |
219 | 208 | | |
220 | 209 | | |
221 | | - | |
| 210 | + | |
222 | 211 | | |
223 | | - | |
224 | 212 | | |
225 | 213 | | |
226 | 214 | | |
| |||
347 | 335 | | |
348 | 336 | | |
349 | 337 | | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
377 | | - | |
| 338 | + | |
| 339 | + | |
378 | 340 | | |
379 | 341 | | |
380 | 342 | | |
| |||
0 commit comments