Skip to content

Commit 1746d4d

Browse files
committed
Hotfix: fetch user in case org not found
1 parent 6cc59ab commit 1746d4d

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

app/src/component/Search.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public static function fetchIssues(string $url): Result {
103103
$issue_count = 0;
104104
if ($repoResult->err) {
105105
try {
106-
$orgInfo = Github::getOrg($org);
106+
$orgInfo = Github::getOrgOrUser($org);
107107
$repoInfo = Github::getRepo($org, $repo);
108108
if ($repoInfo['visibility'] !== 'public') {
109109
return err('e_repo_not_public');

app/src/lib/Github.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,22 @@ protected static function client(): Client {
2525
}
2626

2727
/**
28-
* Get repo information
29-
* @param string $org
28+
* Get org or user information
29+
* @param string $handle
3030
* @return array{has_issues:bool,open_issues:int,visibility:string}
3131
*/
32-
public static function getOrg(
33-
string $org
32+
public static function getOrgOrUser(
33+
string $handle
3434
): array {
35-
/** @var \Github\Api\Organization */
36-
$api = static::client()->api('organization');
37-
return $api->show($org);
35+
try {
36+
/** @var \Github\Api\Organization */
37+
$api = static::client()->api('organization');
38+
return $api->show($handle);
39+
} catch (\Throwable) {
40+
/** @var \Github\Api\User */
41+
$api = static::client()->api('user');
42+
return $api->show($handle);
43+
}
3844
}
3945

4046
/**

0 commit comments

Comments
 (0)