diff --git a/crates/grove-providers/src/github.rs b/crates/grove-providers/src/github.rs index 83612ca..f723720 100644 --- a/crates/grove-providers/src/github.rs +++ b/crates/grove-providers/src/github.rs @@ -62,7 +62,13 @@ impl Provider for GitHub { if !v["private"].is_boolean() { return Err(Error::Other("response has no `private` flag".into())); } - Ok(repo(&v)) + let mut r = repo(&v); + // `internal` repos (GitHub Enterprise) have `private: true` but are readable by the + // whole enterprise: only an explicit "private" counts as private. + if let Some(vis) = v["visibility"].as_str() { + r.private = vis == "private"; + } + Ok(r) } fn list_repos(&self) -> Result> { diff --git a/crates/grove-providers/tests/api.rs b/crates/grove-providers/tests/api.rs index eac4456..acf5036 100644 --- a/crates/grove-providers/tests/api.rs +++ b/crates/grove-providers/tests/api.rs @@ -348,4 +348,16 @@ fn get_repo_reports_visibility_on_both_forges() { let gh = GitHub::new(&url, "t".into()); assert!(!gh.get_repo("o", "r").unwrap().private); assert!(rx.recv().unwrap().starts_with("GET /repos/o/r ")); + + // An internal repo reports `private: true` but is not private. + let (url, _rx) = mock(vec![( + 200, + r#"{"name":"r","private":true,"visibility":"internal","owner":{"login":"o"}}"#, + )]); + assert!( + !GitHub::new(&url, "t".into()) + .get_repo("o", "r") + .unwrap() + .private + ); }