Skip to content

Commit 62cfb6e

Browse files
vinokurigclaude
andcommitted
Remove Gitea compatibility check from GitHub URL parser
The isGiteaCompatibleServer() fallback method and its invocation have been removed to simplify the authentication detection logic. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent a16f5e0 commit 62cfb6e

1 file changed

Lines changed: 4 additions & 27 deletions

File tree

wsmaster/che-core-api-factory-github-common/src/main/java/org/eclipse/che/api/factory/server/github/AbstractGithubURLParser.java

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -149,39 +149,16 @@ private boolean isApiRequestRelevant(String repositoryUrl) {
149149
return e.getMessage().contains("Requires authentication")
150150
|| // for older GitHub Enterprise versions
151151
e.getMessage().contains("Must authenticate to access this API.");
152-
} catch (ScmItemNotFoundException e) {
153-
// GitHub API v3 (/api/v3/user) returned 404 — this server does not expose the GitHub
154-
// v3 API path. Fall back to checking the Gitea-compatible API (/api/v1/user): if that
155-
// endpoint returns 401 the server is a GitHub-compatible instance (e.g. Gitea).
156-
return isGiteaCompatibleServer(serverUrl);
157-
} catch (ScmBadRequestException | IllegalArgumentException | ScmCommunicationException e) {
152+
} catch (ScmItemNotFoundException
153+
| ScmBadRequestException
154+
| IllegalArgumentException
155+
| ScmCommunicationException e) {
158156
return false;
159157
}
160158
}
161159
return false;
162160
}
163161

164-
/**
165-
* Returns {@code true} when the server at {@code serverUrl} exposes a Gitea-style GitHub
166-
* compatible API ({@code /api/v1/user}) and requires authentication (HTTP 401).
167-
*/
168-
private boolean isGiteaCompatibleServer(String serverUrl) {
169-
try {
170-
HttpRequest request =
171-
HttpRequest.newBuilder()
172-
.uri(URI.create(serverUrl + "/api/v1/user"))
173-
.timeout(Duration.ofSeconds(10))
174-
.GET()
175-
.build();
176-
HttpResponse<Void> response =
177-
HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.discarding());
178-
return response.statusCode() == 401;
179-
} catch (Exception e) {
180-
LOG.debug("Failed to reach Gitea API at {}: {}", serverUrl, e.getMessage());
181-
return false;
182-
}
183-
}
184-
185162
private Optional<String> getServerUrl(String repositoryUrl) {
186163
// If the given repository url is an SSH url, generate the base url from the pattern:
187164
// https://<hostname extracted from the SSH url>.

0 commit comments

Comments
 (0)