mirror of
https://github.com/Dasemu/Grove.git
synced 2026-11-26 15:26:09 +00:00
fix(providers): GitHub reply without visibility is unknown
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8bcdcd5771
commit
2b8a8c498d
2 files changed
+13
-4
No files matched your search
@@ -65,9 +65,11 @@ impl Provider for GitHub {
|
||||
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";
|
||||
}
|
||||
// Without the field we cannot tell private from internal: refuse to guess.
|
||||
let vis = v["visibility"]
|
||||
.as_str()
|
||||
.ok_or_else(|| Error::Other("response has no `visibility` field".into()))?;
|
||||
r.private = vis == "private";
|
||||
Ok(r)
|
||||
}
|
||||
|
||||
|
||||
@@ -343,12 +343,19 @@ fn get_repo_reports_visibility_on_both_forges() {
|
||||
|
||||
let (url, rx) = mock(vec![(
|
||||
200,
|
||||
r#"{"name":"r","private":false,"clone_url":"u","default_branch":"main","owner":{"login":"o"}}"#,
|
||||
r#"{"name":"r","private":false,"visibility":"public","clone_url":"u","default_branch":"main","owner":{"login":"o"}}"#,
|
||||
)]);
|
||||
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 "));
|
||||
|
||||
// No `visibility` field: unknown, never guessed from `private`.
|
||||
let (url, _rx) = mock(vec![(
|
||||
200,
|
||||
r#"{"name":"r","private":true,"owner":{"login":"o"}}"#,
|
||||
)]);
|
||||
assert!(GitHub::new(&url, "t".into()).get_repo("o", "r").is_err());
|
||||
|
||||
// An internal repo reports `private: true` but is not private.
|
||||
let (url, _rx) = mock(vec![(
|
||||
200,
|
||||
|
||||
Reference in new issue
Block a user