mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
When a repo has migrated to v2, print message about updating remote
This commit is contained in:
parent
c553094a60
commit
326d0a0722
2 changed files with 33 additions and 6 deletions
|
@ -15,11 +15,30 @@ public class MissingRepositoryException extends SnapshotAPIException {
|
|||
"If this problem persists, please contact us."
|
||||
);
|
||||
|
||||
public static final List<String> EXPORTED_TO_V2 = Arrays.asList(
|
||||
"This Overleaf project has been moved to Overleaf v2, and git access is temporarily unsupported.",
|
||||
static List<String> 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.",
|
||||
"",
|
||||
"See https://www.overleaf.com/help/342 for more information."
|
||||
"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<String> descriptionLines;
|
||||
|
||||
|
|
|
@ -79,9 +79,17 @@ public abstract class Request<T extends Result> {
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue