mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 14:13:43 +01:00
Merge pull request #34450 from overleaf/dp-handle-dot-git-error
[git-bridge] Surface GitUserException messages to the git client GitOrigin-RevId: 45256ca8005142a0f70839e2567341a5984955a7
This commit is contained in:
+12
-1
@@ -2,6 +2,7 @@ package uk.ac.ic.wlgitbridge.git.handler;
|
||||
|
||||
import com.google.api.client.auth.oauth2.Credential;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.Optional;
|
||||
import org.eclipse.jgit.errors.RepositoryNotFoundException;
|
||||
@@ -102,8 +103,18 @@ public class WLRepositoryResolver implements RepositoryResolver<HttpServletReque
|
||||
} catch (ForbiddenException e) {
|
||||
throw new ServiceNotAuthorizedException();
|
||||
} catch (GitUserException e) {
|
||||
/*
|
||||
* Deliver the user-facing message as a git "ERR" pkt-line. ServiceMayNotContinueException
|
||||
* defaults to a 403 status, but the git client only parses the pkt-line body (and so only
|
||||
* displays the message) when the smart-HTTP advertisement is returned with a 200 status; on
|
||||
* any other status it just prints "The requested URL returned error: <code>" and discards
|
||||
* the body. So we explicitly use a 200 status here to surface messages such as the
|
||||
* "project contains a '.git' entity" error to the user.
|
||||
*/
|
||||
throw new ServiceMayNotContinueException(
|
||||
e.getMessage() + "\n" + String.join("\n", e.getDescriptionLines()), e);
|
||||
e.getMessage() + "\n" + String.join("\n", e.getDescriptionLines()),
|
||||
e,
|
||||
HttpServletResponse.SC_OK);
|
||||
} catch (IOException e) {
|
||||
Log.warn("IOException when trying to open repo: " + projName, e);
|
||||
throw new ServiceMayNotContinueException("Internal server error.");
|
||||
|
||||
@@ -88,14 +88,8 @@ public abstract class Request<T extends Result> {
|
||||
if ("projectHasDotGit".equals(code)) {
|
||||
throw new MissingRepositoryException(
|
||||
Arrays.asList(
|
||||
"This project contains a '.git' entity at the top level, indicating that it is",
|
||||
"already a git repository. The Overleaf git-bridge cannot work with this project",
|
||||
"due to a known problem with handling these '.git' folders.",
|
||||
"",
|
||||
"We recommend removing the .git folder before trying again.",
|
||||
"",
|
||||
"If this is unexpected, please contact us at support@overleaf.com, or",
|
||||
"see https://www.overleaf.com/learn/how-to/Git_integration for more information."));
|
||||
"Git access won't work when a project contains a folder named '.git'.",
|
||||
"Please remove any folder named '.git' from your project in Overleaf and try again."));
|
||||
} else {
|
||||
throw new MissingRepositoryException(Arrays.asList("Conflict: 409"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user