Skip to content

Commit 964ae59

Browse files
authored
fix(guard): remove unused org-ownership functions blocking release (#4290)
## Problem The Release workflow ([run #24740822133](https://github.com/github/gh-aw-mcpg/actions/runs/24740822133)) failed in the `docker` job because the Rust guard build has `-D warnings` enabled and two functions trigger dead_code warnings: ``` error: function `get_cached_owner_is_org` is never used --> src/labels/backend.rs:63 error: function `is_repo_org_owned` is never used --> src/labels/backend.rs:282 ``` ## Fix Remove the two unused functions (`get_cached_owner_is_org` and `is_repo_org_owned`) and their associated tests. These were added for future org-ownership detection but are never called from production code. The cache *setter* (`set_cached_owner_is_org`) is retained — it's called during `is_repo_private` lookups to populate the owner-type cache for when these functions are needed later. ## Removed - `get_cached_owner_is_org()` — private cache reader (line 63) - `is_repo_org_owned()` — public API (line 282) - `test_is_repo_org_owned_uses_cache` — test - `test_is_repo_org_owned_empty_args` — test ## Verification `make agent-finished` passes (format, build, lint, all tests including Rust guard).
2 parents 33edc25 + c75059b commit 964ae59

1 file changed

Lines changed: 0 additions & 45 deletions

File tree

  • guards/github-guard/rust-guard/src/labels

guards/github-guard/rust-guard/src/labels/backend.rs

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,6 @@ fn set_cached_repo_visibility(repo_id: &str, is_private: bool) {
6060
}
6161
}
6262

63-
fn get_cached_owner_is_org(repo_id: &str) -> Option<bool> {
64-
repo_owner_type_cache()
65-
.lock()
66-
.ok()
67-
.and_then(|cache| cache.get(repo_id).copied())
68-
}
69-
7063
fn set_cached_owner_is_org(repo_id: &str, is_org: bool) {
7164
if let Ok(mut cache) = repo_owner_type_cache().lock() {
7265
cache.insert(repo_id.to_string(), is_org);
@@ -271,21 +264,6 @@ pub fn is_repo_private_with_callback(
271264
get_cached_repo_visibility(&repo_id)
272265
}
273266

274-
/// Check whether a repository is owned by an organization (vs a personal account).
275-
/// This is determined from the `owner.type` field in the search_repositories response,
276-
/// which is cached alongside repo visibility during `is_repo_private` calls.
277-
///
278-
/// Returns:
279-
/// - `Some(true)` if the owner is an Organization
280-
/// - `Some(false)` if the owner is a User (personal account)
281-
/// - `None` if the owner type could not be determined
282-
pub fn is_repo_org_owned(owner: &str, repo: &str) -> Option<bool> {
283-
if owner.is_empty() || repo.is_empty() {
284-
return None;
285-
}
286-
let repo_id = format!("{}/{}", owner, repo);
287-
get_cached_owner_is_org(&repo_id)
288-
}
289267

290268
/// Fetch pull request facts used for integrity derivation.
291269
pub fn get_pull_request_facts_with_callback(
@@ -1217,12 +1195,6 @@ mod tests {
12171195

12181196
// --- Owner type (org vs user) tests ---
12191197

1220-
fn clear_owner_type_cache_for_tests() {
1221-
if let Ok(mut cache) = repo_owner_type_cache().lock() {
1222-
cache.clear();
1223-
}
1224-
}
1225-
12261198
#[test]
12271199
fn test_owner_type_from_repo_object_org() {
12281200
let item = serde_json::json!({
@@ -1309,23 +1281,6 @@ mod tests {
13091281
});
13101282
assert_eq!(extract_owner_is_org(&response, "myorg/myrepo"), None);
13111283
}
1312-
1313-
#[test]
1314-
fn test_is_repo_org_owned_uses_cache() {
1315-
clear_owner_type_cache_for_tests();
1316-
set_cached_owner_is_org("cached-org/repo", true);
1317-
assert_eq!(is_repo_org_owned("cached-org", "repo"), Some(true));
1318-
1319-
set_cached_owner_is_org("cached-user/repo", false);
1320-
assert_eq!(is_repo_org_owned("cached-user", "repo"), Some(false));
1321-
clear_owner_type_cache_for_tests();
1322-
}
1323-
1324-
#[test]
1325-
fn test_is_repo_org_owned_empty_args() {
1326-
assert_eq!(is_repo_org_owned("", "repo"), None);
1327-
assert_eq!(is_repo_org_owned("owner", ""), None);
1328-
}
13291284
}
13301285

13311286
fn repo_visibility_from_items(value: &Value, repo_id: &str) -> Option<bool> {

0 commit comments

Comments
 (0)