From bfb37e2bf7f65f7cac0c2fbb9d79af1127522bf0 Mon Sep 17 00:00:00 2001 From: Mykola Morhun Date: Wed, 2 Oct 2019 16:49:35 +0300 Subject: [PATCH 1/3] Add sparseCheckoutDir parameter into devfile spec Signed-off-by: Mykola Morhun --- .../model/workspace/config/SourceStorage.java | 6 ++++ .../core/model/workspace/devfile/Source.java | 6 ++++ .../github/GithubSourceStorageBuilder.java | 1 - .../shared/dto/devfile/SourceDto.java | 7 ++++ .../api/workspace/server/DtoConverter.java | 3 +- .../devfile/convert/ProjectConverter.java | 10 +++++- .../server/model/impl/devfile/SourceImpl.java | 32 ++++++++++++++--- .../main/resources/schema/1.0.0/devfile.json | 8 +++++ .../devfile/convert/ProjectConverterTest.java | 25 +++++++++----- .../validator/DevfileSchemaValidatorTest.java | 3 +- .../server/spi/tck/WorkspaceDaoTest.java | 34 +++++++++++++++---- .../devfile_with_sparse_checkout_dir.yaml | 24 +++++++++++++ ...add_devfile_source_sparse_checkout_dir.sql | 13 +++++++ .../che/core/db/jpa/TestObjectsFactory.java | 3 +- 14 files changed, 152 insertions(+), 23 deletions(-) create mode 100644 wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/devfile/devfile_with_sparse_checkout_dir.yaml create mode 100644 wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.3.0/1__add_devfile_source_sparse_checkout_dir.sql diff --git a/core/che-core-api-model/src/main/java/org/eclipse/che/api/core/model/workspace/config/SourceStorage.java b/core/che-core-api-model/src/main/java/org/eclipse/che/api/core/model/workspace/config/SourceStorage.java index 962480b2ffd..3fb32ef9966 100644 --- a/core/che-core-api-model/src/main/java/org/eclipse/che/api/core/model/workspace/config/SourceStorage.java +++ b/core/che-core-api-model/src/main/java/org/eclipse/che/api/core/model/workspace/config/SourceStorage.java @@ -40,6 +40,12 @@ public interface SourceStorage { */ String START_POINT_PARAMETER_NAME = "startPoint"; + /** + * The key with this name in the parameters designates the directory that should be used for + * sparse checkout, i.e. the only directory of repository which should be created by git. + */ + String SPARSE_CHECKOUT_DIR_PARAMETER_NAME = "sparseCheckoutDir"; + String getType(); String getLocation(); diff --git a/core/che-core-api-model/src/main/java/org/eclipse/che/api/core/model/workspace/devfile/Source.java b/core/che-core-api-model/src/main/java/org/eclipse/che/api/core/model/workspace/devfile/Source.java index 5b9ab9981e6..528531ac385 100644 --- a/core/che-core-api-model/src/main/java/org/eclipse/che/api/core/model/workspace/devfile/Source.java +++ b/core/che-core-api-model/src/main/java/org/eclipse/che/api/core/model/workspace/devfile/Source.java @@ -39,4 +39,10 @@ public interface Source { * 'startPoint' and provided for convenience. */ String getCommitId(); + + /** + * The directory which is kept by sparse checkout. If this parameter is not null then the only + * given directory will be present after clone. + */ + String getSparseCheckoutDir(); } diff --git a/wsmaster/che-core-api-factory-github/src/main/java/org/eclipse/che/api/factory/server/github/GithubSourceStorageBuilder.java b/wsmaster/che-core-api-factory-github/src/main/java/org/eclipse/che/api/factory/server/github/GithubSourceStorageBuilder.java index ec1731a9c2b..ac9a250459f 100644 --- a/wsmaster/che-core-api-factory-github/src/main/java/org/eclipse/che/api/factory/server/github/GithubSourceStorageBuilder.java +++ b/wsmaster/che-core-api-factory-github/src/main/java/org/eclipse/che/api/factory/server/github/GithubSourceStorageBuilder.java @@ -56,7 +56,6 @@ public SourceStorageDto buildWorkspaceConfigSource(GithubUrl githubUrl) { * @return newly created source DTO object */ public SourceDto buildDevfileSource(GithubUrl githubUrl) { - // T_O_D_O add keepDir support when Devfile will support it return newDto(SourceDto.class) .withLocation(githubUrl.repositoryLocation()) .withType("github") diff --git a/wsmaster/che-core-api-workspace-shared/src/main/java/org/eclipse/che/api/workspace/shared/dto/devfile/SourceDto.java b/wsmaster/che-core-api-workspace-shared/src/main/java/org/eclipse/che/api/workspace/shared/dto/devfile/SourceDto.java index 9cf074010b5..937ce1b039f 100644 --- a/wsmaster/che-core-api-workspace-shared/src/main/java/org/eclipse/che/api/workspace/shared/dto/devfile/SourceDto.java +++ b/wsmaster/che-core-api-workspace-shared/src/main/java/org/eclipse/che/api/workspace/shared/dto/devfile/SourceDto.java @@ -59,4 +59,11 @@ public interface SourceDto extends Source { void setCommitId(String commitId); SourceDto withCommitId(String commitId); + + @Override + String getSparseCheckoutDir(); + + void setSparseCheckoutDir(String sparseCheckoutDir); + + SourceDto withSparseCheckoutDir(String sparseCheckoutDir); } diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/DtoConverter.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/DtoConverter.java index 3b92ae1007a..0f5cb5c0187 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/DtoConverter.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/DtoConverter.java @@ -128,7 +128,8 @@ private static ProjectDto asDto(Project project) { .withBranch(source.getBranch()) .withStartPoint(source.getStartPoint()) .withTag(source.getTag()) - .withCommitId(source.getCommitId())); + .withCommitId(source.getCommitId()) + .withSparseCheckoutDir(source.getSparseCheckoutDir())); } private static ComponentDto asDto(Component component) { diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/convert/ProjectConverter.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/convert/ProjectConverter.java index 476bea814e9..80fa445a900 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/convert/ProjectConverter.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/devfile/convert/ProjectConverter.java @@ -14,6 +14,7 @@ import static java.lang.String.format; import static org.eclipse.che.api.core.model.workspace.config.SourceStorage.BRANCH_PARAMETER_NAME; import static org.eclipse.che.api.core.model.workspace.config.SourceStorage.COMMIT_ID_PARAMETER_NAME; +import static org.eclipse.che.api.core.model.workspace.config.SourceStorage.SPARSE_CHECKOUT_DIR_PARAMETER_NAME; import static org.eclipse.che.api.core.model.workspace.config.SourceStorage.START_POINT_PARAMETER_NAME; import static org.eclipse.che.api.core.model.workspace.config.SourceStorage.TAG_PARAMETER_NAME; @@ -46,6 +47,8 @@ public ProjectImpl toDevfileProject(ProjectConfigImpl projectConfig) { String startPoint = projectConfig.getSource().getParameters().get(START_POINT_PARAMETER_NAME); String tag = projectConfig.getSource().getParameters().get(TAG_PARAMETER_NAME); String commitId = projectConfig.getSource().getParameters().get(COMMIT_ID_PARAMETER_NAME); + String sparseCheckoutDir = + projectConfig.getSource().getParameters().get(SPARSE_CHECKOUT_DIR_PARAMETER_NAME); SourceImpl source = new SourceImpl( @@ -54,7 +57,8 @@ public ProjectImpl toDevfileProject(ProjectConfigImpl projectConfig) { branch, startPoint, tag, - commitId); + commitId, + sparseCheckoutDir); String path = projectConfig.getPath(); while (path != null && path.startsWith("/")) { @@ -186,5 +190,9 @@ private void updateSourceStorage(Source devfileSource, SourceStorageImpl sourceS } else if (commitId != null) { sourceStorage.getParameters().put(COMMIT_ID_PARAMETER_NAME, commitId); } + + if (devfileSource.getSparseCheckoutDir() != null) { + sourceStorage.getParameters().put("keepDir", devfileSource.getSparseCheckoutDir()); + } } } diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/devfile/SourceImpl.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/devfile/SourceImpl.java index e83036e9b54..05b5554247a 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/devfile/SourceImpl.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/devfile/SourceImpl.java @@ -38,16 +38,26 @@ public class SourceImpl implements Source { @Column(name = "commit_id") private String commitId; + @Column(name = "sparse_checkout_dir") + private String sparseCheckoutDir; + public SourceImpl() {} public SourceImpl( - String type, String location, String branch, String startPoint, String tag, String commitId) { + String type, + String location, + String branch, + String startPoint, + String tag, + String commitId, + String sparseCheckoutDir) { this.type = type; this.location = location; this.branch = branch; this.startPoint = startPoint; this.tag = tag; this.commitId = commitId; + this.sparseCheckoutDir = sparseCheckoutDir; } public SourceImpl(Source source) { @@ -57,7 +67,8 @@ public SourceImpl(Source source) { source.getBranch(), source.getStartPoint(), source.getTag(), - source.getCommitId()); + source.getCommitId(), + source.getSparseCheckoutDir()); } @Override @@ -114,6 +125,15 @@ public void setCommitId(String commitId) { this.commitId = commitId; } + @Override + public String getSparseCheckoutDir() { + return sparseCheckoutDir; + } + + public void setSparseCheckoutDir(String sparseCheckoutDir) { + this.sparseCheckoutDir = sparseCheckoutDir; + } + @Override public boolean equals(Object o) { if (this == o) { @@ -128,12 +148,13 @@ public boolean equals(Object o) { && Objects.equals(branch, source.branch) && Objects.equals(startPoint, source.startPoint) && Objects.equals(tag, source.tag) - && Objects.equals(commitId, source.commitId); + && Objects.equals(commitId, source.commitId) + && Objects.equals(sparseCheckoutDir, source.sparseCheckoutDir); } @Override public int hashCode() { - return Objects.hash(type, location, branch, startPoint, tag, commitId); + return Objects.hash(type, location, branch, startPoint, tag, commitId, sparseCheckoutDir); } @Override @@ -157,6 +178,9 @@ public String toString() { + ", commitId='" + commitId + '\'' + + ", sparseCheckoutDir='" + + sparseCheckoutDir + + '\'' + '}'; } } diff --git a/wsmaster/che-core-api-workspace/src/main/resources/schema/1.0.0/devfile.json b/wsmaster/che-core-api-workspace/src/main/resources/schema/1.0.0/devfile.json index 0f2ebbd89cb..a7320e393a0 100644 --- a/wsmaster/che-core-api-workspace/src/main/resources/schema/1.0.0/devfile.json +++ b/wsmaster/che-core-api-workspace/src/main/resources/schema/1.0.0/devfile.json @@ -142,6 +142,14 @@ "examples": [ "349d3ad" ] + }, + "sparseCheckoutDir": { + "type": "string", + "description": "The directory which will be created with sparse checkout.", + "examples": [ + "core/", + "wsmaster/che-core-api-workspace/" + ] } } }, diff --git a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/devfile/convert/ProjectConverterTest.java b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/devfile/convert/ProjectConverterTest.java index 5c130fa5155..82eae34e2ea 100644 --- a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/devfile/convert/ProjectConverterTest.java +++ b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/devfile/convert/ProjectConverterTest.java @@ -13,6 +13,7 @@ import static org.eclipse.che.api.core.model.workspace.config.SourceStorage.BRANCH_PARAMETER_NAME; import static org.eclipse.che.api.core.model.workspace.config.SourceStorage.COMMIT_ID_PARAMETER_NAME; +import static org.eclipse.che.api.core.model.workspace.config.SourceStorage.SPARSE_CHECKOUT_DIR_PARAMETER_NAME; import static org.eclipse.che.api.core.model.workspace.config.SourceStorage.START_POINT_PARAMETER_NAME; import static org.eclipse.che.api.core.model.workspace.config.SourceStorage.TAG_PARAMETER_NAME; import static org.testng.Assert.assertEquals; @@ -46,7 +47,7 @@ public void testConvertingDevfileProjectToProjectConfig() throws Exception { new ProjectImpl( "myProject", new SourceImpl( - "git", "https://github.com/eclipse/che.git", "master", "3434d", null, null), + "git", "https://github.com/eclipse/che.git", "master", "3434d", null, null, "core"), null); ProjectConfigImpl workspaceProject = projectConverter.toWorkspaceProject(devfileProject); @@ -58,6 +59,7 @@ public void testConvertingDevfileProjectToProjectConfig() throws Exception { assertEquals(source.getLocation(), "https://github.com/eclipse/che.git"); assertEquals(source.getParameters().get(BRANCH_PARAMETER_NAME), "master"); assertEquals(source.getParameters().get(START_POINT_PARAMETER_NAME), "3434d"); + assertEquals(source.getParameters().get("keepDir"), "core"); } @Test @@ -88,7 +90,8 @@ public void testClonePathSetWhenConvertingDevfileToProjectConfig() throws Except ProjectImpl devfileProject = new ProjectImpl( "myProject", - new SourceImpl("git", "https://github.com/eclipse/che.git", "master", null, null, null), + new SourceImpl( + "git", "https://github.com/eclipse/che.git", "master", null, null, null, null), "down/the/rabbit/hole/myProject"); ProjectConfigImpl workspaceProject = projectConverter.toWorkspaceProject(devfileProject); @@ -105,7 +108,8 @@ public void testClonePathCannotEscapeProjectsRoot() throws Exception { ProjectImpl devfileProject = new ProjectImpl( "myProject", - new SourceImpl("git", "https://github.com/eclipse/che.git", "master", null, null, null), + new SourceImpl( + "git", "https://github.com/eclipse/che.git", "master", null, null, null, null), "cant/hack/../../../usr/bin"); projectConverter.toWorkspaceProject(devfileProject); @@ -116,7 +120,8 @@ public void testClonePathCannotBeAbsolute() throws Exception { ProjectImpl devfileProject = new ProjectImpl( "myProject", - new SourceImpl("git", "https://github.com/eclipse/che.git", "master", null, null, null), + new SourceImpl( + "git", "https://github.com/eclipse/che.git", "master", null, null, null, null), "/usr/bin"); projectConverter.toWorkspaceProject(devfileProject); @@ -127,7 +132,8 @@ public void testUpDirOkInClonePathAsLongAsItDoesntEscapeProjectsRoot() throws Ex ProjectImpl devfileProject = new ProjectImpl( "myProject", - new SourceImpl("git", "https://github.com/eclipse/che.git", "master", null, null, null), + new SourceImpl( + "git", "https://github.com/eclipse/che.git", "master", null, null, null, null), "cant/hack/../../usr/bin"); ProjectConfigImpl workspaceProject = projectConverter.toWorkspaceProject(devfileProject); @@ -140,7 +146,8 @@ public void testCloningIntoProjectsRootFails() throws Exception { ProjectImpl devfileProject = new ProjectImpl( "myProject", - new SourceImpl("git", "https://github.com/eclipse/che.git", "master", null, null, null), + new SourceImpl( + "git", "https://github.com/eclipse/che.git", "master", null, null, null, null), "not/../in/root/../.."); projectConverter.toWorkspaceProject(devfileProject); @@ -163,7 +170,7 @@ public void testOnlyOneOfStartPointAttributesAllowed( new ProjectImpl( "myProject", new SourceImpl( - "git", "https://github.com/eclipse/che.git", null, startPoint, tag, commitId), + "git", "https://github.com/eclipse/che.git", null, startPoint, tag, commitId, null), null); projectConverter.toWorkspaceProject(devfileProject); @@ -184,7 +191,8 @@ public void testUndefinedCloneParametersNotTransferredToWorkspaceConfig() throws ProjectImpl devfileProject = new ProjectImpl( "myProject", - new SourceImpl("git", "https://github.com/eclipse/che.git", null, null, null, null), + new SourceImpl( + "git", "https://github.com/eclipse/che.git", null, null, null, null, null), null); ProjectConfigImpl wsProject = projectConverter.toWorkspaceProject(devfileProject); @@ -194,5 +202,6 @@ public void testUndefinedCloneParametersNotTransferredToWorkspaceConfig() throws assertFalse(wsSource.getParameters().containsKey(START_POINT_PARAMETER_NAME)); assertFalse(wsSource.getParameters().containsKey(TAG_PARAMETER_NAME)); assertFalse(wsSource.getParameters().containsKey(COMMIT_ID_PARAMETER_NAME)); + assertFalse(wsSource.getParameters().containsKey(SPARSE_CHECKOUT_DIR_PARAMETER_NAME)); } } diff --git a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/devfile/validator/DevfileSchemaValidatorTest.java b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/devfile/validator/DevfileSchemaValidatorTest.java index bd5361db8d1..64eab51294d 100644 --- a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/devfile/validator/DevfileSchemaValidatorTest.java +++ b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/devfile/validator/DevfileSchemaValidatorTest.java @@ -67,7 +67,8 @@ public Object[][] validDevfiles() { {"editor_plugin_component/devfile_editor_plugins_components_with_memory_limit.yaml"}, {"editor_plugin_component/devfile_plugin_component_with_reference.yaml"}, {"devfile/devfile_just_generatename.yaml"}, - {"devfile/devfile_name_and_generatename.yaml"} + {"devfile/devfile_name_and_generatename.yaml"}, + {"devfile/devfile_with_sparse_checkout_dir.yaml"} }; } diff --git a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/spi/tck/WorkspaceDaoTest.java b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/spi/tck/WorkspaceDaoTest.java index 8b1a6be919a..efe8541a88d 100644 --- a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/spi/tck/WorkspaceDaoTest.java +++ b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/spi/tck/WorkspaceDaoTest.java @@ -535,7 +535,14 @@ public void shouldUpdateWorkspaceWithDevfile() throws Exception { workspace.getDevfile().getProjects().remove(1); final SourceImpl source3 = - new SourceImpl("type3", "http://location", "branch3", "point3", "tag3", "commit3"); + new SourceImpl( + "type3", + "http://location", + "branch3", + "point3", + "tag3", + "commit3", + "sparseCheckoutDir3"); ProjectImpl newProject = new ProjectImpl("project3", source3, "path3"); workspace.getDevfile().getProjects().add(newProject); @@ -544,9 +551,10 @@ public void shouldUpdateWorkspaceWithDevfile() throws Exception { projectCfg.getSource().setLocation("new-location"); projectCfg.getSource().setType("new-type"); projectCfg.getSource().setBranch("new-branch"); - projectCfg.getSource().setCommitId(("new-commit")); - projectCfg.getSource().setTag(("new-tag")); - projectCfg.getSource().setStartPoint(("new-point")); + projectCfg.getSource().setCommitId("new-commit"); + projectCfg.getSource().setTag("new-tag"); + projectCfg.getSource().setStartPoint("new-point"); + projectCfg.getSource().setSparseCheckoutDir("new-sparse-checkout-dir"); // Remove an existing command workspace.getDevfile().getCommands().remove(1); @@ -854,11 +862,25 @@ public static WorkspaceImpl createWorkspaceFromDevfile( private static DevfileImpl createDevfile(String name) { SourceImpl source1 = - new SourceImpl("type1", "http://location", "branch1", "point1", "tag1", "commit1"); + new SourceImpl( + "type1", + "http://location", + "branch1", + "point1", + "tag1", + "commit1", + "sparseCheckoutDir1"); ProjectImpl project1 = new ProjectImpl("project1", source1, "path1"); SourceImpl source2 = - new SourceImpl("type2", "http://location", "branch2", "point2", "tag2", "commit2"); + new SourceImpl( + "type2", + "http://location", + "branch2", + "point2", + "tag2", + "commit2", + "sparseCheckoutDir2"); ProjectImpl project2 = new ProjectImpl("project2", source2, "path2"); ActionImpl action1 = diff --git a/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/devfile/devfile_with_sparse_checkout_dir.yaml b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/devfile/devfile_with_sparse_checkout_dir.yaml new file mode 100644 index 00000000000..ec89e4b735c --- /dev/null +++ b/wsmaster/che-core-api-workspace/src/test/resources/devfile/schema_test/devfile/devfile_with_sparse_checkout_dir.yaml @@ -0,0 +1,24 @@ +# +# Copyright (c) 2012-2018 Red Hat, Inc. +# This program and the accompanying materials are made +# available under the terms of the Eclipse Public License 2.0 +# which is available at https://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 +# +# Contributors: +# Red Hat, Inc. - initial API and implementation +# + +--- +apiVersion: 1.0.0 +metadata: + name: spring-integration-samples + generateName: spring-integration-samples- +projects: + - name: spring-integration-samples + source: + type: git + location: 'https://github.com/spring-projects/spring-integration-samples.git' + branch: master + sparseCheckoutDir: basic/http/ diff --git a/wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.3.0/1__add_devfile_source_sparse_checkout_dir.sql b/wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.3.0/1__add_devfile_source_sparse_checkout_dir.sql new file mode 100644 index 00000000000..df4deafef42 --- /dev/null +++ b/wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.3.0/1__add_devfile_source_sparse_checkout_dir.sql @@ -0,0 +1,13 @@ +-- +-- Copyright (c) 2012-2019 Red Hat, Inc. +-- This program and the accompanying materials are made +-- available under the terms of the Eclipse Public License 2.0 +-- which is available at https://www.eclipse.org/legal/epl-2.0/ +-- +-- SPDX-License-Identifier: EPL-2.0 +-- +-- Contributors: +-- Red Hat, Inc. - initial API and implementation +-- + +ALTER TABLE devfile_project ADD COLUMN sparse_checkout_dir TEXT; diff --git a/wsmaster/integration-tests/cascade-removal/src/test/java/org/eclipse/che/core/db/jpa/TestObjectsFactory.java b/wsmaster/integration-tests/cascade-removal/src/test/java/org/eclipse/che/core/db/jpa/TestObjectsFactory.java index 9606a92a52f..0f9c5b489e2 100644 --- a/wsmaster/integration-tests/cascade-removal/src/test/java/org/eclipse/che/core/db/jpa/TestObjectsFactory.java +++ b/wsmaster/integration-tests/cascade-removal/src/test/java/org/eclipse/che/core/db/jpa/TestObjectsFactory.java @@ -154,7 +154,8 @@ private static ProjectImpl createDevfileProject(String name) { } private static SourceImpl createDevfileSource() { - return new SourceImpl("type", "http://location", "branch1", "point1", "tag1", "commit1"); + return new SourceImpl( + "type", "http://location", "branch1", "point1", "tag1", "commit1", "sparseCheckoutDir1"); } public static CommandImpl createCommand() { From c0128db61b9fa3d53ad3975cc6edee4bf8630f3d Mon Sep 17 00:00:00 2001 From: Mykola Morhun Date: Thu, 10 Oct 2019 16:19:37 +0300 Subject: [PATCH 2/3] Changes accordinig to PR feedback Signed-off-by: Mykola Morhun --- .../factory/server/github/GithubSourceStorageBuilder.java | 3 ++- .../src/main/resources/schema/1.0.0/devfile.json | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/wsmaster/che-core-api-factory-github/src/main/java/org/eclipse/che/api/factory/server/github/GithubSourceStorageBuilder.java b/wsmaster/che-core-api-factory-github/src/main/java/org/eclipse/che/api/factory/server/github/GithubSourceStorageBuilder.java index ac9a250459f..cc68d21ac29 100644 --- a/wsmaster/che-core-api-factory-github/src/main/java/org/eclipse/che/api/factory/server/github/GithubSourceStorageBuilder.java +++ b/wsmaster/che-core-api-factory-github/src/main/java/org/eclipse/che/api/factory/server/github/GithubSourceStorageBuilder.java @@ -59,6 +59,7 @@ public SourceDto buildDevfileSource(GithubUrl githubUrl) { return newDto(SourceDto.class) .withLocation(githubUrl.repositoryLocation()) .withType("github") - .withBranch(githubUrl.getBranch()); + .withBranch(githubUrl.getBranch()) + .withSparseCheckoutDir(githubUrl.getSubfolder()); } } diff --git a/wsmaster/che-core-api-workspace/src/main/resources/schema/1.0.0/devfile.json b/wsmaster/che-core-api-workspace/src/main/resources/schema/1.0.0/devfile.json index a7320e393a0..a5838df2e5b 100644 --- a/wsmaster/che-core-api-workspace/src/main/resources/schema/1.0.0/devfile.json +++ b/wsmaster/che-core-api-workspace/src/main/resources/schema/1.0.0/devfile.json @@ -145,10 +145,13 @@ }, "sparseCheckoutDir": { "type": "string", - "description": "The directory which will be created with sparse checkout.", + "description": "Part of project to populate in the working directory.", "examples": [ + "/core/", "core/", - "wsmaster/che-core-api-workspace/" + "core", + "/wsmaster/che-core-api-workspace/", + "/d*" ] } } From fc47388dfcb982a12d75438e46d9e9609d295ca2 Mon Sep 17 00:00:00 2001 From: Mykola Morhun Date: Wed, 16 Oct 2019 14:48:07 +0300 Subject: [PATCH 3/3] Move migration script to 7.4 version Signed-off-by: Mykola Morhun --- .../1__add_devfile_source_sparse_checkout_dir.sql | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename wsmaster/che-core-sql-schema/src/main/resources/che-schema/{7.3.0 => 7.4.0}/1__add_devfile_source_sparse_checkout_dir.sql (100%) diff --git a/wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.3.0/1__add_devfile_source_sparse_checkout_dir.sql b/wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.4.0/1__add_devfile_source_sparse_checkout_dir.sql similarity index 100% rename from wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.3.0/1__add_devfile_source_sparse_checkout_dir.sql rename to wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.4.0/1__add_devfile_source_sparse_checkout_dir.sql