diff --git a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/base/MissingRepositoryException.java b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/base/MissingRepositoryException.java index c39f6c2481..0056dfbeef 100644 --- a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/base/MissingRepositoryException.java +++ b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/base/MissingRepositoryException.java @@ -15,11 +15,30 @@ public class MissingRepositoryException extends SnapshotAPIException { "If this problem persists, please contact us." ); - public static final List EXPORTED_TO_V2 = Arrays.asList( - "This Overleaf project has been moved to Overleaf v2, and git access is temporarily unsupported.", - "", - "See https://www.overleaf.com/help/342 for more information." - ); + static List buildExportedToV2Message(String remoteUrl) { + if (remoteUrl == null) { + return Arrays.asList( + "This Overleaf project has been moved to Overleaf v2, and cannot be used with git at this time.", + "", + "If this error persists, please contact us at support@overleaf.com, or", + "see https://www.overleaf.com/help/342 for more information." + ); + } else { + return Arrays.asList( + "This Overleaf project has been moved to Overleaf v2, You should change your remote to:", + "", + " " + remoteUrl, + "", + "Assuming you are using the default \"origin\" remote, the following commands", + "will change the remote for you:", + "", + " git remote set-url origin " + remoteUrl, + "", + "If this does not work, contact us at support@overleaf.com, or", + "see https://www.overleaf.com/help/342 for more information." + ); + } + } private List descriptionLines; diff --git a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/base/Request.java b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/base/Request.java index 34fabb794e..2f95c46e5d 100644 --- a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/base/Request.java +++ b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/base/Request.java @@ -79,9 +79,17 @@ public abstract class Request { try { JsonObject json = Instance.gson.fromJson(httpCause.getContent(), JsonObject.class); String message = json.get("message").getAsString(); + String newRemote; + if (json.has("new_remote")) { + newRemote = json.get("new_remote").getAsString(); + } else { + newRemote = null; + } if ("Exported to v2".equals(message)) { - throw new MissingRepositoryException(MissingRepositoryException.EXPORTED_TO_V2); + throw new MissingRepositoryException( + MissingRepositoryException.buildExportedToV2Message(newRemote) + ); } } catch (IllegalStateException | ClassCastException