mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 17:33:40 -05:00
Fix issue with pulling 2 new identical binary files with known name
This commit is contained in:
parent
4fbd6eaabe
commit
70c963c38f
12 changed files with 167 additions and 4 deletions
|
@ -38,11 +38,13 @@ public class ResourceFetcher {
|
||||||
} else {
|
} else {
|
||||||
Util.sout("Found (" + projectName + "): " + url);
|
Util.sout("Found (" + projectName + "): " + url);
|
||||||
Util.sout("At (" + projectName + "): " + path);
|
Util.sout("At (" + projectName + "): " + path);
|
||||||
RawFile rawFile = new RepositoryObjectTreeWalker(repository).getDirectoryContents().getFileTable().get(path);
|
|
||||||
if (rawFile != null) {
|
|
||||||
contents = rawFile.getContents();
|
|
||||||
} else {
|
|
||||||
contents = fetchedUrls.get(url);
|
contents = fetchedUrls.get(url);
|
||||||
|
if (contents == null) {
|
||||||
|
RawFile rawFile = new RepositoryObjectTreeWalker(repository).getDirectoryContents().getFileTable().get(path);
|
||||||
|
if (rawFile == null) {
|
||||||
|
throw new IllegalStateException("file was not in the current commit, or the git tree, yet path was not null");
|
||||||
|
}
|
||||||
|
contents = rawFile.getContents();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new RepositoryFile(newPath, contents);
|
return new RepositoryFile(newPath, contents);
|
||||||
|
|
|
@ -63,6 +63,10 @@ public class WLGitBridgeIntegrationTest {
|
||||||
put("canCloneDuplicateBinaryFiles", new HashMap<String, SnapshotAPIState>() {{
|
put("canCloneDuplicateBinaryFiles", new HashMap<String, SnapshotAPIState>() {{
|
||||||
put("state", new SnapshotAPIStateBuilder(getResourceAsStream("/canCloneDuplicateBinaryFiles/state/state.json")).build());
|
put("state", new SnapshotAPIStateBuilder(getResourceAsStream("/canCloneDuplicateBinaryFiles/state/state.json")).build());
|
||||||
}});
|
}});
|
||||||
|
put("canPullUpdatedBinaryFiles", new HashMap<String, SnapshotAPIState>() {{
|
||||||
|
put("base", new SnapshotAPIStateBuilder(getResourceAsStream("/canPullUpdatedBinaryFiles/base/state.json")).build());
|
||||||
|
put("withUpdatedBinaryFiles", new SnapshotAPIStateBuilder(getResourceAsStream("/canPullUpdatedBinaryFiles/withUpdatedBinaryFiles/state.json")).build());
|
||||||
|
}});
|
||||||
put("canPullAModifiedNestedFile", new HashMap<String, SnapshotAPIState>() {{
|
put("canPullAModifiedNestedFile", new HashMap<String, SnapshotAPIState>() {{
|
||||||
put("base", new SnapshotAPIStateBuilder(getResourceAsStream("/canPullAModifiedNestedFile/base/state.json")).build());
|
put("base", new SnapshotAPIStateBuilder(getResourceAsStream("/canPullAModifiedNestedFile/base/state.json")).build());
|
||||||
put("withModifiedNestedFile", new SnapshotAPIStateBuilder(getResourceAsStream("/canPullAModifiedNestedFile/withModifiedNestedFile/state.json")).build());
|
put("withModifiedNestedFile", new SnapshotAPIStateBuilder(getResourceAsStream("/canPullAModifiedNestedFile/withModifiedNestedFile/state.json")).build());
|
||||||
|
@ -294,6 +298,29 @@ public class WLGitBridgeIntegrationTest {
|
||||||
assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/canCloneDuplicateBinaryFiles/state/testproj"), testprojDir.toPath()));
|
assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/canCloneDuplicateBinaryFiles/state/testproj"), testprojDir.toPath()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void canPullUpdatedBinaryFiles() throws IOException, GitAPIException, InterruptedException {
|
||||||
|
MockSnapshotServer server = new MockSnapshotServer(4003, getResource("/canPullUpdatedBinaryFiles").toFile());
|
||||||
|
server.start();
|
||||||
|
server.setState(states.get("canPullUpdatedBinaryFiles").get("base"));
|
||||||
|
GitBridgeApp wlgb = new GitBridgeApp(new String[] {
|
||||||
|
makeConfigFile(44003, 4003)
|
||||||
|
});
|
||||||
|
wlgb.run();
|
||||||
|
File dir = folder.newFolder();
|
||||||
|
Process gitBase = runtime.exec("git clone http://127.0.0.1:44003/testproj.git", null, dir);
|
||||||
|
int exitCodeBase = gitBase.waitFor();
|
||||||
|
File testprojDir = new File(dir, "testproj");
|
||||||
|
assertEquals(0, exitCodeBase);
|
||||||
|
assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/canPullUpdatedBinaryFiles/base/testproj"), testprojDir.toPath()));
|
||||||
|
server.setState(states.get("canPullUpdatedBinaryFiles").get("withUpdatedBinaryFiles"));
|
||||||
|
Process gitWithDeletedBinaryFile = runtime.exec("git pull", null, testprojDir);
|
||||||
|
int exitCodeWithDeletedBinaryFile = gitWithDeletedBinaryFile.waitFor();
|
||||||
|
wlgb.stop();
|
||||||
|
assertEquals(0, exitCodeWithDeletedBinaryFile);
|
||||||
|
assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/canPullUpdatedBinaryFiles/withUpdatedBinaryFiles/testproj"), testprojDir.toPath()));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void canPullAModifiedNestedFile() throws IOException, GitAPIException, InterruptedException {
|
public void canPullAModifiedNestedFile() throws IOException, GitAPIException, InterruptedException {
|
||||||
MockSnapshotServer server = new MockSnapshotServer(3864, getResource("/canPullAModifiedNestedFile").toFile());
|
MockSnapshotServer server = new MockSnapshotServer(3864, getResource("/canPullAModifiedNestedFile").toFile());
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"project": "testproj",
|
||||||
|
"getDoc": {
|
||||||
|
"versionID": 1,
|
||||||
|
"createdAt": "2014-11-30T18:40:58.123Z",
|
||||||
|
"email": "jdleesmiller+1@gmail.com",
|
||||||
|
"name": "John+1"
|
||||||
|
},
|
||||||
|
"getSavedVers": [
|
||||||
|
{
|
||||||
|
"versionID": 1,
|
||||||
|
"comment": "added more info on doc GET and error details",
|
||||||
|
"email": "jdleesmiller+1@gmail.com",
|
||||||
|
"name": "John+1",
|
||||||
|
"createdAt": "2014-11-30T18:47:01.456Z"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"getForVers": [
|
||||||
|
{
|
||||||
|
"versionID": 1,
|
||||||
|
"srcs": [
|
||||||
|
{
|
||||||
|
"content": "content\n",
|
||||||
|
"path": "main.tex"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"content": "This text is from another file.",
|
||||||
|
"path": "test.tex"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"atts": [
|
||||||
|
{
|
||||||
|
"url": "http://127.0.0.1:4003/base/testproj/overleaf-white-410.png",
|
||||||
|
"path": "overleaf-white-410.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "http://127.0.0.1:4003/base/testproj/overleaf-white-410.png",
|
||||||
|
"path": "overleaf-white-410-copy.png"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"push": "success",
|
||||||
|
"postback": {
|
||||||
|
"type": "success",
|
||||||
|
"versionID": 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
|
@ -0,0 +1 @@
|
||||||
|
content
|
Binary file not shown.
After Width: | Height: | Size: 8.6 KiB |
Binary file not shown.
After Width: | Height: | Size: 8.6 KiB |
|
@ -0,0 +1 @@
|
||||||
|
This text is from another file.
|
|
@ -0,0 +1,80 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"project": "testproj",
|
||||||
|
"getDoc": {
|
||||||
|
"versionID": 2,
|
||||||
|
"createdAt": "2014-11-30T18:40:58.123Z",
|
||||||
|
"email": "jdleesmiller+1@gmail.com",
|
||||||
|
"name": "John+1"
|
||||||
|
},
|
||||||
|
"getSavedVers": [
|
||||||
|
{
|
||||||
|
"versionID": 2,
|
||||||
|
"comment": "i deleted the image",
|
||||||
|
"email": "jdleesmiller+1@gmail.com",
|
||||||
|
"name": "John+1",
|
||||||
|
"createdAt": "2014-11-30T18:48:01.123Z"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"versionID": 1,
|
||||||
|
"comment": "added more info on doc GET and error details",
|
||||||
|
"email": "jdleesmiller+1@gmail.com",
|
||||||
|
"name": "John+1",
|
||||||
|
"createdAt": "2014-11-30T18:47:01.456Z"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"getForVers": [
|
||||||
|
{
|
||||||
|
"versionID": 2,
|
||||||
|
"srcs": [
|
||||||
|
{
|
||||||
|
"content": "content\n",
|
||||||
|
"path": "main.tex"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"content": "This text is from another file.",
|
||||||
|
"path": "test.tex"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"atts": [
|
||||||
|
{
|
||||||
|
"url": "http://127.0.0.1:4003/withUpdatedBinaryFiles/testproj/overleaf-white-410.png",
|
||||||
|
"path": "overleaf-white-410.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "http://127.0.0.1:4003/withUpdatedBinaryFiles/testproj/overleaf-white-410.png",
|
||||||
|
"path": "overleaf-white-410-copy.png"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"versionID": 1,
|
||||||
|
"srcs": [
|
||||||
|
{
|
||||||
|
"content": "content\n",
|
||||||
|
"path": "main.tex"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"content": "This text is from another file.",
|
||||||
|
"path": "test.tex"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"atts": [
|
||||||
|
{
|
||||||
|
"url": "http://127.0.0.1:4003/base/testproj/overleaf-white-410.png",
|
||||||
|
"path": "overleaf-white-410.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "http://127.0.0.1:4003/base/testproj/overleaf-white-410.png",
|
||||||
|
"path": "overleaf-white-410-copy.png"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"push": "success",
|
||||||
|
"postback": {
|
||||||
|
"type": "success",
|
||||||
|
"versionID": 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
|
@ -0,0 +1 @@
|
||||||
|
content
|
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
|
@ -0,0 +1 @@
|
||||||
|
This text is from another file.
|
Loading…
Reference in a new issue