mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-30 20:31:34 +02:00
Better javadoc, improve handling of submodules
This commit is contained in:
@@ -107,6 +107,9 @@ public class WLGitBridgeIntegrationTest {
|
||||
put("wlgbCanSwapProjects", new HashMap<String, SnapshotAPIState>() {{
|
||||
put("state", new SnapshotAPIStateBuilder(getResourceAsStream("/wlgbCanSwapProjects/state/state.json")).build());
|
||||
}});
|
||||
put("pushSubmoduleFailsWithInvalidGitRepo", new HashMap<String, SnapshotAPIState>() {{
|
||||
put("state", new SnapshotAPIStateBuilder(getResourceAsStream("/pushSubmoduleFailsWithInvalidGitRepo/state/state.json")).build());
|
||||
}});
|
||||
}};
|
||||
|
||||
@Rule
|
||||
@@ -624,6 +627,43 @@ public class WLGitBridgeIntegrationTest {
|
||||
wlgb.stop();
|
||||
}
|
||||
|
||||
private static final List<String> EXPECTED_OUT_PUSH_SUBMODULE = Arrays.asList(
|
||||
"remote: hint: Your Git repository is invalid.",
|
||||
"remote: hint: If your project contains a Git submodule,",
|
||||
"remote: hint: please remove it and try again.",
|
||||
"To http://127.0.0.1:33875/testproj.git",
|
||||
"! [remote rejected] master -> master (invalid git repo)",
|
||||
"error: failed to push some refs to 'http://127.0.0.1:33875/testproj.git'"
|
||||
);
|
||||
|
||||
@Test
|
||||
public void pushSubmoduleFailsWithInvalidGitRepo() throws IOException, GitAPIException, InterruptedException {
|
||||
MockSnapshotServer server = new MockSnapshotServer(3875, getResource("/pushSubmoduleFailsWithInvalidGitRepo").toFile());
|
||||
server.start();
|
||||
server.setState(states.get("pushSubmoduleFailsWithInvalidGitRepo").get("state"));
|
||||
GitBridgeApp wlgb = new GitBridgeApp(new String[] {
|
||||
makeConfigFile(33875, 3875)
|
||||
});
|
||||
wlgb.run();
|
||||
File dir = folder.newFolder();
|
||||
File testprojDir = cloneRepository("testproj", 33875, dir);
|
||||
runtime.exec("mkdir sub", null, testprojDir).waitFor();
|
||||
File sub = new File(testprojDir, "sub");
|
||||
runtime.exec("touch sub.txt", null, sub).waitFor();
|
||||
runtime.exec("git init", null, sub).waitFor();
|
||||
runtime.exec("git add -A", null, sub).waitFor();
|
||||
runtime.exec("git commit -m \"sub\"", null, sub).waitFor();
|
||||
runtime.exec("git add -A", null, testprojDir).waitFor();
|
||||
runtime.exec("git commit -m \"push\"", null, testprojDir).waitFor();
|
||||
Process gitPush = runtime.exec("git push", null, testprojDir);
|
||||
int pushExitCode = gitPush.waitFor();
|
||||
wlgb.stop();
|
||||
assertEquals(1, pushExitCode);
|
||||
List<String> actual = Util.linesFromStream(gitPush.getErrorStream(), 2, "[K");
|
||||
assertEquals(EXPECTED_OUT_PUSH_SUBMODULE, actual);
|
||||
wlgb.stop();
|
||||
}
|
||||
|
||||
private File cloneRepository(String repositoryName, int port, File dir) throws IOException, InterruptedException {
|
||||
String repo = "git clone http://127.0.0.1:" + port + "/" + repositoryName + ".git";
|
||||
Process gitProcess = runtime.exec(repo, null, dir);
|
||||
|
||||
Reference in New Issue
Block a user