chore: added git resource map consumption (#38470)
## Description - Added git resource map consumption Fixes #`Issue Number` _or_ Fixes `Issue URL` > [!WARNING] > _If no issue exists, please create an issue first, and check with the maintainers if the issue is valid._ ## Automation /ok-to-test tags="@tag.Git" it=true ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/12600209771> > Commit: 8877a5b92ae5bcb25b428ed50fe09a8d0b767e35 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=12600209771&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.Git` > Spec: > <hr>Fri, 03 Jan 2025 16:35:41 UTC <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit Based on the comprehensive summary of changes, here are the release notes: ## Release Notes - **Git Integration Enhancements** - Improved Git reference handling across multiple service methods - Enhanced support for artifact migration and JSON schema transformations - Refined parameter management for Git-related operations - **Method Signature Updates** - Standardized method signatures across Git-related services - Added support for more flexible reference type handling - Improved consistency in method parameter ordering - **Backend Improvements** - Updated JSON migration processes - Enhanced error handling in Git file system operations - Expanded support for different artifact types in Git workflows - **Testing and Validation** - Updated test cases to reflect new method signatures - Improved test coverage for Git-related functionality These changes primarily focus on backend improvements to the Git integration system, providing more robust and flexible handling of artifacts and references. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
parent
9ce2598e76
commit
649338d188
|
|
@ -674,6 +674,13 @@ public class FileUtilsCEImpl implements FileInterface {
|
|||
.subscribeOn(scheduler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<GitResourceMap> constructGitResourceMapFromGitRepo(Path repositorySuffix, String refName) {
|
||||
// TODO: check that we need to checkout to the ref
|
||||
Path repositoryPath = Paths.get(gitServiceConfig.getGitRootPath()).resolve(repositorySuffix);
|
||||
return Mono.fromCallable(() -> fetchGitResourceMap(repositoryPath)).subscribeOn(scheduler);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is used to initialize repo with Readme file when the application is connected to remote repo
|
||||
*
|
||||
|
|
|
|||
|
|
@ -50,6 +50,8 @@ public interface FileInterface {
|
|||
Mono<ApplicationGitReference> reconstructApplicationReferenceFromGitRepo(
|
||||
String organisationId, String baseApplicationId, String repoName, String branchName);
|
||||
|
||||
Mono<GitResourceMap> constructGitResourceMapFromGitRepo(Path repositorySuffix, String refName);
|
||||
|
||||
/**
|
||||
* This method just reconstructs the metdata of the json from git repo.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.appsmith.server.applications.git;
|
||||
|
||||
import com.appsmith.external.git.FileInterface;
|
||||
import com.appsmith.external.git.constants.ce.RefType;
|
||||
import com.appsmith.external.git.models.GitResourceIdentity;
|
||||
import com.appsmith.external.git.models.GitResourceMap;
|
||||
import com.appsmith.external.git.models.GitResourceType;
|
||||
|
|
@ -29,6 +30,7 @@ import com.appsmith.server.dtos.ArtifactExchangeJson;
|
|||
import com.appsmith.server.dtos.PageDTO;
|
||||
import com.appsmith.server.exceptions.AppsmithError;
|
||||
import com.appsmith.server.exceptions.AppsmithException;
|
||||
import com.appsmith.server.git.dtos.ArtifactJsonTransformationDTO;
|
||||
import com.appsmith.server.helpers.CollectionUtils;
|
||||
import com.appsmith.server.helpers.ce.ArtifactGitFileUtilsCE;
|
||||
import com.appsmith.server.migrations.JsonSchemaMigration;
|
||||
|
|
@ -467,10 +469,20 @@ public class ApplicationGitFileUtilsCEImpl implements ArtifactGitFileUtilsCE<App
|
|||
ApplicationJson applicationJson = getApplicationJsonFromGitReference(applicationReference);
|
||||
copyNestedNonNullProperties(metadata, applicationJson);
|
||||
return jsonSchemaMigration.migrateApplicationJsonToLatestSchema(
|
||||
applicationJson, baseArtifactId, branchName);
|
||||
applicationJson, baseArtifactId, branchName, RefType.branch);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<? extends ArtifactExchangeJson> performJsonMigration(
|
||||
ArtifactJsonTransformationDTO jsonTransformationDTO, ArtifactExchangeJson artifactExchangeJson) {
|
||||
String baseArtifactId = jsonTransformationDTO.getBaseArtifactId();
|
||||
String refName = jsonTransformationDTO.getRefName();
|
||||
RefType refType = jsonTransformationDTO.getRefType();
|
||||
return jsonSchemaMigration.migrateArtifactExchangeJsonToLatestSchema(
|
||||
artifactExchangeJson, baseArtifactId, refName, refType);
|
||||
}
|
||||
|
||||
protected <T> List<T> getApplicationResource(Map<String, Object> resources, Type type) {
|
||||
|
||||
List<T> deserializedResources = new ArrayList<>();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.appsmith.server.applications.imports;
|
||||
|
||||
import com.appsmith.external.git.constants.ce.RefType;
|
||||
import com.appsmith.external.models.Datasource;
|
||||
import com.appsmith.external.models.DatasourceStorageDTO;
|
||||
import com.appsmith.server.applications.base.ApplicationService;
|
||||
|
|
@ -643,18 +644,21 @@ public class ApplicationImportServiceCEImpl
|
|||
ApplicationJson applicationJson = (ApplicationJson) artifactExchangeJson;
|
||||
|
||||
if (!hasText(branchedArtifactId)) {
|
||||
return jsonSchemaMigration.migrateApplicationJsonToLatestSchema(applicationJson, null, null);
|
||||
return jsonSchemaMigration.migrateApplicationJsonToLatestSchema(applicationJson, null, null, null);
|
||||
}
|
||||
|
||||
return applicationService.findById(branchedArtifactId).flatMap(application -> {
|
||||
String baseArtifactId = application.getBaseId();
|
||||
String refName = null;
|
||||
RefType refType = null;
|
||||
|
||||
if (application.getGitArtifactMetadata() != null) {
|
||||
refName = application.getGitArtifactMetadata().getRefName();
|
||||
refType = application.getGitArtifactMetadata().getRefType();
|
||||
}
|
||||
|
||||
return jsonSchemaMigration.migrateApplicationJsonToLatestSchema(applicationJson, baseArtifactId, refName);
|
||||
return jsonSchemaMigration.migrateApplicationJsonToLatestSchema(
|
||||
applicationJson, baseArtifactId, refName, refType);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,9 +25,9 @@ public interface CentralGitServiceCE {
|
|||
|
||||
Mono<? extends Artifact> connectArtifactToGit(
|
||||
String baseArtifactId,
|
||||
ArtifactType artifactType,
|
||||
GitConnectDTO gitConnectDTO,
|
||||
String originHeader,
|
||||
ArtifactType artifactType,
|
||||
GitType gitType);
|
||||
|
||||
Mono<String> commitArtifact(
|
||||
|
|
@ -36,44 +36,44 @@ public interface CentralGitServiceCE {
|
|||
Mono<? extends Artifact> detachRemote(String branchedArtifactId, ArtifactType artifactType, GitType gitType);
|
||||
|
||||
Mono<List<GitBranchDTO>> listBranchForArtifact(
|
||||
String branchedArtifactId, Boolean pruneBranches, ArtifactType artifactType, GitType gitType);
|
||||
String branchedArtifactId, ArtifactType artifactType, Boolean pruneBranches, GitType gitType);
|
||||
|
||||
Mono<String> fetchRemoteChanges(
|
||||
String referenceArtifactId,
|
||||
boolean isFileLock,
|
||||
ArtifactType artifactType,
|
||||
boolean isFileLock,
|
||||
GitType gitType,
|
||||
RefType refType);
|
||||
|
||||
Mono<? extends Artifact> discardChanges(String branchedArtifactId, ArtifactType artifactType, GitType gitType);
|
||||
|
||||
Mono<GitStatusDTO> getStatus(
|
||||
String branchedArtifactId, boolean compareRemote, ArtifactType artifactType, GitType gitType);
|
||||
String branchedArtifactId, ArtifactType artifactType, boolean compareRemote, GitType gitType);
|
||||
|
||||
Mono<GitPullDTO> pullArtifact(String branchedArtifactId, ArtifactType artifactType, GitType gitType);
|
||||
|
||||
Mono<? extends Artifact> checkoutReference(
|
||||
String referenceArtifactId,
|
||||
ArtifactType artifactType,
|
||||
GitRefDTO gitRefDTO,
|
||||
boolean addFileLock,
|
||||
ArtifactType artifactType,
|
||||
GitType gitType);
|
||||
|
||||
Mono<? extends Artifact> createReference(
|
||||
String referencedArtifactId, GitRefDTO refDTO, ArtifactType artifactType, GitType gitType);
|
||||
String referencedArtifactId, ArtifactType artifactType, GitRefDTO refDTO, GitType gitType);
|
||||
|
||||
Mono<? extends Artifact> deleteGitReference(
|
||||
String baseArtifactId, GitRefDTO gitRefDTO, ArtifactType artifactType, GitType gitType);
|
||||
String baseArtifactId, ArtifactType artifactType, GitRefDTO gitRefDTO, GitType gitType);
|
||||
|
||||
Mono<List<String>> updateProtectedBranches(
|
||||
String baseArtifactId, List<String> branchNames, ArtifactType artifactType);
|
||||
String baseArtifactId, ArtifactType artifactType, List<String> branchNames);
|
||||
|
||||
Mono<List<String>> getProtectedBranches(String baseArtifactId, ArtifactType artifactType);
|
||||
|
||||
Mono<Boolean> toggleAutoCommitEnabled(String baseArtifactId, ArtifactType artifactType);
|
||||
|
||||
Mono<AutoCommitResponseDTO> getAutoCommitProgress(
|
||||
String baseArtifactId, String branchName, ArtifactType artifactType);
|
||||
String baseArtifactId, ArtifactType artifactType, String branchName);
|
||||
|
||||
Mono<GitAuth> generateSSHKey(String keyType);
|
||||
|
||||
|
|
|
|||
|
|
@ -364,9 +364,9 @@ public class CentralGitServiceCEImpl implements CentralGitServiceCE {
|
|||
@Override
|
||||
public Mono<? extends Artifact> checkoutReference(
|
||||
String referenceArtifactId,
|
||||
ArtifactType artifactType,
|
||||
GitRefDTO gitRefDTO,
|
||||
boolean addFileLock,
|
||||
ArtifactType artifactType,
|
||||
GitType gitType) {
|
||||
|
||||
if (gitRefDTO == null || !hasText(gitRefDTO.getRefName())) {
|
||||
|
|
@ -423,6 +423,7 @@ public class CentralGitServiceCEImpl implements CentralGitServiceCE {
|
|||
ArtifactJsonTransformationDTO jsonTransformationDTO = new ArtifactJsonTransformationDTO();
|
||||
jsonTransformationDTO.setWorkspaceId(baseArtifact.getWorkspaceId());
|
||||
jsonTransformationDTO.setBaseArtifactId(baseGitMetadata.getDefaultArtifactId());
|
||||
jsonTransformationDTO.setRefName(finalRefName);
|
||||
jsonTransformationDTO.setRefType(refType);
|
||||
jsonTransformationDTO.setArtifactType(baseArtifact.getArtifactType());
|
||||
jsonTransformationDTO.setRepoName(baseGitMetadata.getRepoName());
|
||||
|
|
@ -474,7 +475,7 @@ public class CentralGitServiceCEImpl implements CentralGitServiceCE {
|
|||
}
|
||||
|
||||
protected Mono<? extends Artifact> checkoutRemoteReference(
|
||||
String baseArtifactId, GitRefDTO gitRefDTO, ArtifactType artifactType, GitType gitType) {
|
||||
String baseArtifactId, ArtifactType artifactType, GitRefDTO gitRefDTO, GitType gitType) {
|
||||
|
||||
GitArtifactHelper<?> gitArtifactHelper = gitArtifactHelperResolver.getArtifactHelper(artifactType);
|
||||
AclPermission artifactEditPermission = gitArtifactHelper.getArtifactEditPermission();
|
||||
|
|
@ -559,7 +560,7 @@ public class CentralGitServiceCEImpl implements CentralGitServiceCE {
|
|||
|
||||
@Override
|
||||
public Mono<? extends Artifact> createReference(
|
||||
String referencedArtifactId, GitRefDTO refDTO, ArtifactType artifactType, GitType gitType) {
|
||||
String referencedArtifactId, ArtifactType artifactType, GitRefDTO refDTO, GitType gitType) {
|
||||
|
||||
/*
|
||||
1. Check if the src artifact is available and user have sufficient permissions
|
||||
|
|
@ -689,7 +690,7 @@ public class CentralGitServiceCEImpl implements CentralGitServiceCE {
|
|||
})
|
||||
// after the branch is created, we need to reset the older branch to the
|
||||
// clean status, i.e. last commit
|
||||
.doOnSuccess(newImportedArtifact -> discardChanges(sourceArtifact, gitType));
|
||||
.flatMap(newImportedArtifact -> discardChanges(sourceArtifact, gitType));
|
||||
})
|
||||
.flatMap(newImportedArtifact -> gitRedisUtils
|
||||
.releaseFileLock(
|
||||
|
|
@ -729,7 +730,7 @@ public class CentralGitServiceCEImpl implements CentralGitServiceCE {
|
|||
|
||||
@Override
|
||||
public Mono<? extends Artifact> deleteGitReference(
|
||||
String baseArtifactId, GitRefDTO gitRefDTO, ArtifactType artifactType, GitType gitType) {
|
||||
String baseArtifactId, ArtifactType artifactType, GitRefDTO gitRefDTO, GitType gitType) {
|
||||
|
||||
String refName = gitRefDTO.getRefName();
|
||||
RefType refType = gitRefDTO.getRefType();
|
||||
|
|
@ -867,19 +868,19 @@ public class CentralGitServiceCEImpl implements CentralGitServiceCE {
|
|||
* Each artifact is equal to a repo in the git(and each branch creates a new artifact with default artifact as parent)
|
||||
*
|
||||
* @param baseArtifactId : artifactId of the artifact which is getting connected to git
|
||||
* @param gitConnectDTO artifactId - this is used to link the local git repo to an artifact
|
||||
* remoteUrl - used for connecting to remote repo etc
|
||||
* @param originHeader
|
||||
* @param artifactType
|
||||
* @param gitConnectDTO artifactId - this is used to link the local git repo to an artifact
|
||||
* remoteUrl - used for connecting to remote repo etc
|
||||
* @param originHeader
|
||||
* @param gitType
|
||||
* @return an artifact with git metadata
|
||||
*/
|
||||
@Override
|
||||
public Mono<? extends Artifact> connectArtifactToGit(
|
||||
String baseArtifactId,
|
||||
ArtifactType artifactType,
|
||||
GitConnectDTO gitConnectDTO,
|
||||
String originHeader,
|
||||
ArtifactType artifactType,
|
||||
GitType gitType) {
|
||||
/*
|
||||
* Connecting the artifact for the first time
|
||||
|
|
@ -1473,31 +1474,31 @@ public class CentralGitServiceCEImpl implements CentralGitServiceCE {
|
|||
}
|
||||
|
||||
private Mono<GitStatusDTO> getStatusAfterComparingWithRemote(
|
||||
String baseArtifactId, boolean isFileLock, ArtifactType artifactType, GitType gitType) {
|
||||
return getStatus(baseArtifactId, isFileLock, true, artifactType, gitType);
|
||||
String baseArtifactId, ArtifactType artifactType, boolean isFileLock, GitType gitType) {
|
||||
return getStatus(baseArtifactId, artifactType, isFileLock, true, gitType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<GitStatusDTO> getStatus(
|
||||
String branchedArtifactId, boolean compareRemote, ArtifactType artifactType, GitType gitType) {
|
||||
return getStatus(branchedArtifactId, true, compareRemote, artifactType, gitType);
|
||||
String branchedArtifactId, ArtifactType artifactType, boolean compareRemote, GitType gitType) {
|
||||
return getStatus(branchedArtifactId, artifactType, true, compareRemote, gitType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the status of the artifact for given branched id
|
||||
*
|
||||
* @param branchedArtifactId branched id of the artifact
|
||||
* @param artifactType Type of artifact in context
|
||||
* @param isFileLock if the locking is required, since the status API is used in the other flows of git
|
||||
* Only for the direct hits from the client the locking will be added
|
||||
* @param artifactType Type of artifact in context
|
||||
* @param gitType Type of the service
|
||||
* @return Map of json file names which are added, modified, conflicting, removed and the working tree if this is clean
|
||||
*/
|
||||
private Mono<GitStatusDTO> getStatus(
|
||||
String branchedArtifactId,
|
||||
ArtifactType artifactType,
|
||||
boolean isFileLock,
|
||||
boolean compareRemote,
|
||||
ArtifactType artifactType,
|
||||
GitType gitType) {
|
||||
|
||||
Mono<Tuple2<? extends Artifact, ? extends Artifact>> baseAndBranchedArtifacts =
|
||||
|
|
@ -1867,14 +1868,14 @@ public class CentralGitServiceCEImpl implements CentralGitServiceCE {
|
|||
* 1. Checkout (if required) to the branch to make sure we are comparing the right branch
|
||||
* 2. Run a git fetch command to fetch the latest changes from the remote
|
||||
*
|
||||
* @param refArtifactId id of the reference
|
||||
* @param isFileLock whether to add file lock or not
|
||||
* @param refArtifactId id of the reference
|
||||
* @param artifactType
|
||||
* @param isFileLock whether to add file lock or not
|
||||
* @return Mono of {@link BranchTrackingStatus}
|
||||
*/
|
||||
@Override
|
||||
public Mono<String> fetchRemoteChanges(
|
||||
String refArtifactId, boolean isFileLock, ArtifactType artifactType, GitType gitType, RefType refType) {
|
||||
String refArtifactId, ArtifactType artifactType, boolean isFileLock, GitType gitType, RefType refType) {
|
||||
GitArtifactHelper<?> artifactGitHelper = gitArtifactHelperResolver.getArtifactHelper(artifactType);
|
||||
AclPermission artifactEditPermission = artifactGitHelper.getArtifactEditPermission();
|
||||
|
||||
|
|
@ -2066,15 +2067,15 @@ public class CentralGitServiceCEImpl implements CentralGitServiceCE {
|
|||
}
|
||||
|
||||
public Mono<List<GitBranchDTO>> listBranchForArtifact(
|
||||
String branchedArtifactId, Boolean pruneBranches, ArtifactType artifactType, GitType gitType) {
|
||||
return getBranchList(branchedArtifactId, pruneBranches, true, artifactType, gitType);
|
||||
String branchedArtifactId, ArtifactType artifactType, Boolean pruneBranches, GitType gitType) {
|
||||
return getBranchList(branchedArtifactId, artifactType, pruneBranches, true, gitType);
|
||||
}
|
||||
|
||||
protected Mono<List<GitBranchDTO>> getBranchList(
|
||||
String branchedArtifactId,
|
||||
ArtifactType artifactType,
|
||||
Boolean pruneBranches,
|
||||
boolean syncDefaultBranchWithRemote,
|
||||
ArtifactType artifactType,
|
||||
GitType gitType) {
|
||||
|
||||
GitArtifactHelper<?> gitArtifactHelper = gitArtifactHelperResolver.getArtifactHelper(artifactType);
|
||||
|
|
@ -2176,9 +2177,9 @@ public class CentralGitServiceCEImpl implements CentralGitServiceCE {
|
|||
// default branch has been changed in remote
|
||||
return updateDefaultBranchName(
|
||||
metadata.getDefaultArtifactId(),
|
||||
artifactType,
|
||||
defaultBranchNameInRemote,
|
||||
jsonTransformationDTO,
|
||||
artifactType,
|
||||
gitType)
|
||||
.then()
|
||||
.thenReturn(defaultBranchNameInRemote);
|
||||
|
|
@ -2191,9 +2192,9 @@ public class CentralGitServiceCEImpl implements CentralGitServiceCE {
|
|||
|
||||
private Flux<? extends Artifact> updateDefaultBranchName(
|
||||
String baseArtifactId,
|
||||
ArtifactType artifactType,
|
||||
String newDefaultBranchName,
|
||||
ArtifactJsonTransformationDTO jsonTransformationDTO,
|
||||
ArtifactType artifactType,
|
||||
GitType gitType) {
|
||||
// Get the artifact from DB by new defaultBranchName
|
||||
GitArtifactHelper<?> gitArtifactHelper = gitArtifactHelperResolver.getArtifactHelper(artifactType);
|
||||
|
|
@ -2391,7 +2392,7 @@ public class CentralGitServiceCEImpl implements CentralGitServiceCE {
|
|||
|
||||
@Override
|
||||
public Mono<List<String>> updateProtectedBranches(
|
||||
String baseArtifactId, List<String> branchNames, ArtifactType artifactType) {
|
||||
String baseArtifactId, ArtifactType artifactType, List<String> branchNames) {
|
||||
|
||||
GitArtifactHelper<?> gitArtifactHelper = gitArtifactHelperResolver.getArtifactHelper(artifactType);
|
||||
AclPermission artifactManageProtectedBranchPermission =
|
||||
|
|
@ -2508,7 +2509,7 @@ public class CentralGitServiceCEImpl implements CentralGitServiceCE {
|
|||
|
||||
@Override
|
||||
public Mono<AutoCommitResponseDTO> getAutoCommitProgress(
|
||||
String artifactId, String branchName, ArtifactType artifactType) {
|
||||
String artifactId, ArtifactType artifactType, String branchName) {
|
||||
return gitAutoCommitHelper.getAutoCommitProgress(artifactId, branchName);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ public class GitApplicationControllerCE {
|
|||
@RequestBody GitConnectDTO gitConnectDTO,
|
||||
@RequestHeader("Origin") String originHeader) {
|
||||
return centralGitService
|
||||
.connectArtifactToGit(applicationId, gitConnectDTO, originHeader, ARTIFACT_TYPE, GIT_TYPE)
|
||||
.connectArtifactToGit(applicationId, ARTIFACT_TYPE, gitConnectDTO, originHeader, GIT_TYPE)
|
||||
.map(application -> new ResponseDTO<>(HttpStatus.OK.value(), application, null));
|
||||
}
|
||||
|
||||
|
|
@ -95,7 +95,7 @@ public class GitApplicationControllerCE {
|
|||
referencedApplicationId,
|
||||
srcBranch);
|
||||
return centralGitService
|
||||
.createReference(referencedApplicationId, gitRefDTO, ArtifactType.APPLICATION, GIT_TYPE)
|
||||
.createReference(referencedApplicationId, ArtifactType.APPLICATION, gitRefDTO, GIT_TYPE)
|
||||
.map(result -> new ResponseDTO<>(HttpStatus.CREATED.value(), result, null));
|
||||
}
|
||||
|
||||
|
|
@ -104,7 +104,7 @@ public class GitApplicationControllerCE {
|
|||
public Mono<ResponseDTO<? extends Artifact>> checkoutReference(
|
||||
@PathVariable String referencedApplicationId, @RequestBody GitRefDTO gitRefDTO) {
|
||||
return centralGitService
|
||||
.checkoutReference(referencedApplicationId, gitRefDTO, true, ARTIFACT_TYPE, GIT_TYPE)
|
||||
.checkoutReference(referencedApplicationId, ARTIFACT_TYPE, gitRefDTO, true, GIT_TYPE)
|
||||
.map(result -> new ResponseDTO<>(HttpStatus.OK.value(), result, null));
|
||||
}
|
||||
|
||||
|
|
@ -133,7 +133,7 @@ public class GitApplicationControllerCE {
|
|||
@RequestParam(required = false, defaultValue = "true") Boolean compareRemote) {
|
||||
log.info("Going to get status for branchedApplicationId {}", branchedApplicationId);
|
||||
return centralGitService
|
||||
.getStatus(branchedApplicationId, compareRemote, ARTIFACT_TYPE, GIT_TYPE)
|
||||
.getStatus(branchedApplicationId, ARTIFACT_TYPE, compareRemote, GIT_TYPE)
|
||||
.map(result -> new ResponseDTO<>(HttpStatus.OK.value(), result, null));
|
||||
}
|
||||
|
||||
|
|
@ -144,7 +144,7 @@ public class GitApplicationControllerCE {
|
|||
@RequestHeader(required = false, defaultValue = "branch") RefType refType) {
|
||||
log.info("Going to compare with remote for default referencedApplicationId {}", referencedApplicationId);
|
||||
return centralGitService
|
||||
.fetchRemoteChanges(referencedApplicationId, true, ARTIFACT_TYPE, GIT_TYPE, refType)
|
||||
.fetchRemoteChanges(referencedApplicationId, ARTIFACT_TYPE, true, GIT_TYPE, refType)
|
||||
.map(result -> new ResponseDTO<>(HttpStatus.OK.value(), result, null));
|
||||
}
|
||||
|
||||
|
|
@ -154,7 +154,7 @@ public class GitApplicationControllerCE {
|
|||
@PathVariable String baseArtifactId, @RequestBody GitRefDTO gitRefDTO) {
|
||||
log.info("Going to delete ref {} for baseApplicationId {}", gitRefDTO.getRefName(), baseArtifactId);
|
||||
return centralGitService
|
||||
.deleteGitReference(baseArtifactId, gitRefDTO, ARTIFACT_TYPE, GIT_TYPE)
|
||||
.deleteGitReference(baseArtifactId, ARTIFACT_TYPE, gitRefDTO, GIT_TYPE)
|
||||
.map(application -> new ResponseDTO<>(HttpStatus.OK.value(), application, null));
|
||||
}
|
||||
|
||||
|
|
@ -173,7 +173,7 @@ public class GitApplicationControllerCE {
|
|||
@PathVariable String baseArtifactId,
|
||||
@RequestBody @Valid BranchProtectionRequestDTO branchProtectionRequestDTO) {
|
||||
return centralGitService
|
||||
.updateProtectedBranches(baseArtifactId, branchProtectionRequestDTO.getBranchNames(), ARTIFACT_TYPE)
|
||||
.updateProtectedBranches(baseArtifactId, ARTIFACT_TYPE, branchProtectionRequestDTO.getBranchNames())
|
||||
.map(data -> new ResponseDTO<>(HttpStatus.OK.value(), data, null));
|
||||
}
|
||||
|
||||
|
|
@ -199,7 +199,7 @@ public class GitApplicationControllerCE {
|
|||
@PathVariable String baseApplicationId,
|
||||
@RequestHeader(name = FieldName.BRANCH_NAME, required = false) String branchName) {
|
||||
return centralGitService
|
||||
.getAutoCommitProgress(baseApplicationId, branchName, ARTIFACT_TYPE)
|
||||
.getAutoCommitProgress(baseApplicationId, ARTIFACT_TYPE, branchName)
|
||||
.map(data -> new ResponseDTO<>(HttpStatus.OK.value(), data, null));
|
||||
}
|
||||
|
||||
|
|
@ -219,7 +219,7 @@ public class GitApplicationControllerCE {
|
|||
log.debug("Going to get branch list for application {}", branchedApplicationId);
|
||||
return centralGitService
|
||||
.listBranchForArtifact(
|
||||
branchedApplicationId, BooleanUtils.isTrue(pruneBranches), ARTIFACT_TYPE, GIT_TYPE)
|
||||
branchedApplicationId, ARTIFACT_TYPE, BooleanUtils.isTrue(pruneBranches), GIT_TYPE)
|
||||
.map(result -> new ResponseDTO<>(HttpStatus.OK.value(), result, null));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -209,12 +209,8 @@ public class GitFSServiceCEImpl implements GitHandlingServiceCE {
|
|||
@Override
|
||||
public Mono<? extends ArtifactExchangeJson> reconstructArtifactJsonFromGitRepository(
|
||||
ArtifactJsonTransformationDTO artifactJsonTransformationDTO) {
|
||||
return commonGitFileUtils.reconstructArtifactExchangeJsonFromGitRepoWithAnalytics(
|
||||
artifactJsonTransformationDTO.getWorkspaceId(),
|
||||
artifactJsonTransformationDTO.getBaseArtifactId(),
|
||||
artifactJsonTransformationDTO.getRepoName(),
|
||||
artifactJsonTransformationDTO.getRefName(),
|
||||
artifactJsonTransformationDTO.getArtifactType());
|
||||
return commonGitFileUtils.constructArtifactExchangeJsonFromGitRepositoryWithAnalytics(
|
||||
artifactJsonTransformationDTO);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -367,7 +363,7 @@ public class GitFSServiceCEImpl implements GitHandlingServiceCE {
|
|||
Path repoSuffix = gitArtifactHelper.getRepoSuffixPath(workspaceId, baseArtifactId, repoName);
|
||||
|
||||
return commonGitFileUtils
|
||||
.saveArtifactToLocalRepoWithAnalytics(repoSuffix, artifactExchangeJson, branchName)
|
||||
.saveArtifactToLocalRepoNew(repoSuffix, artifactExchangeJson, branchName)
|
||||
.map(ignore -> Boolean.TRUE)
|
||||
.onErrorResume(e -> {
|
||||
log.error("Error in commit flow: ", e);
|
||||
|
|
@ -376,6 +372,7 @@ public class GitFSServiceCEImpl implements GitHandlingServiceCE {
|
|||
} else if (e instanceof AppsmithException) {
|
||||
return Mono.error(e);
|
||||
}
|
||||
|
||||
return Mono.error(new AppsmithException(AppsmithError.GIT_FILE_SYSTEM_ERROR, e.getMessage()));
|
||||
});
|
||||
}
|
||||
|
|
@ -617,8 +614,7 @@ public class GitFSServiceCEImpl implements GitHandlingServiceCE {
|
|||
Path repoSuffix = gitArtifactHelper.getRepoSuffixPath(workspaceId, baseArtifactId, repoName);
|
||||
|
||||
return fsGitHandler.rebaseBranch(repoSuffix, refName).flatMap(rebaseStatus -> {
|
||||
return commonGitFileUtils.reconstructArtifactExchangeJsonFromGitRepoWithAnalytics(
|
||||
workspaceId, baseArtifactId, repoName, refName, artifactType);
|
||||
return commonGitFileUtils.constructArtifactExchangeJsonFromGitRepository(jsonTransformationDTO);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.appsmith.server.helpers.ce;
|
|||
import com.appsmith.external.git.models.GitResourceMap;
|
||||
import com.appsmith.external.models.ArtifactGitReference;
|
||||
import com.appsmith.server.dtos.ArtifactExchangeJson;
|
||||
import com.appsmith.server.git.dtos.ArtifactJsonTransformationDTO;
|
||||
import lombok.NonNull;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
|
|
@ -28,4 +29,7 @@ public interface ArtifactGitFileUtilsCE<T extends ArtifactGitReference> {
|
|||
Path getRepoSuffixPath(String workspaceId, String artifactId, String repoName, @NonNull String... args);
|
||||
|
||||
void setArtifactDependentPropertiesInJson(GitResourceMap gitResourceMap, ArtifactExchangeJson artifactExchangeJson);
|
||||
|
||||
Mono<? extends ArtifactExchangeJson> performJsonMigration(
|
||||
ArtifactJsonTransformationDTO jsonTransformationDTO, ArtifactExchangeJson artifactExchangeJson);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import com.appsmith.server.dtos.ArtifactExchangeJson;
|
|||
import com.appsmith.server.dtos.PageDTO;
|
||||
import com.appsmith.server.exceptions.AppsmithError;
|
||||
import com.appsmith.server.exceptions.AppsmithException;
|
||||
import com.appsmith.server.git.dtos.ArtifactJsonTransformationDTO;
|
||||
import com.appsmith.server.helpers.ArtifactGitFileUtils;
|
||||
import com.appsmith.server.migrations.JsonSchemaVersions;
|
||||
import com.appsmith.server.newactions.base.NewActionService;
|
||||
|
|
@ -159,16 +160,19 @@ public class CommonGitFileUtilsCE {
|
|||
}
|
||||
|
||||
public Mono<Path> saveArtifactToLocalRepoNew(
|
||||
Path baseRepoSuffix, ArtifactExchangeJson artifactExchangeJson, String branchName)
|
||||
throws IOException, GitAPIException {
|
||||
Path baseRepoSuffix, ArtifactExchangeJson artifactExchangeJson, String branchName) {
|
||||
|
||||
// this should come from the specific files
|
||||
GitResourceMap gitResourceMap = createGitResourceMap(artifactExchangeJson);
|
||||
|
||||
// Save application to git repo
|
||||
return fileUtils
|
||||
.saveArtifactToGitRepo(baseRepoSuffix, gitResourceMap, branchName)
|
||||
.subscribeOn(Schedulers.boundedElastic());
|
||||
try {
|
||||
return fileUtils
|
||||
.saveArtifactToGitRepo(baseRepoSuffix, gitResourceMap, branchName)
|
||||
.subscribeOn(Schedulers.boundedElastic());
|
||||
} catch (IOException | GitAPIException exception) {
|
||||
return Mono.error(exception);
|
||||
}
|
||||
}
|
||||
|
||||
public Mono<Path> saveArtifactToLocalRepoWithAnalytics(
|
||||
|
|
@ -553,6 +557,96 @@ public class CommonGitFileUtilsCE {
|
|||
artifactGitReference.setDatasources(resourceMap);
|
||||
}
|
||||
|
||||
public Mono<? extends ArtifactExchangeJson> constructArtifactExchangeJsonFromGitRepositoryWithAnalytics(
|
||||
ArtifactJsonTransformationDTO jsonTransformationDTO) {
|
||||
if (!isJsonTransformationDTOValid(jsonTransformationDTO)) {
|
||||
return Mono.error(new AppsmithException(
|
||||
AppsmithError.INVALID_GIT_CONFIGURATION, "ArtifactJSONTransformationDTO is invalid"));
|
||||
}
|
||||
|
||||
String workspaceId = jsonTransformationDTO.getWorkspaceId();
|
||||
String baseArtifactId = jsonTransformationDTO.getBaseArtifactId();
|
||||
|
||||
ArtifactGitFileUtils<?> artifactGitFileUtils =
|
||||
getArtifactBasedFileHelper(jsonTransformationDTO.getArtifactType());
|
||||
Map<String, String> constantsMap = artifactGitFileUtils.getConstantsMap();
|
||||
|
||||
return Mono.zip(
|
||||
constructArtifactExchangeJsonFromGitRepository(jsonTransformationDTO),
|
||||
sessionUserService.getCurrentUser())
|
||||
.flatMap(tuple -> {
|
||||
final Map<String, Object> data = Map.of(
|
||||
constantsMap.get(FieldName.ID),
|
||||
baseArtifactId,
|
||||
FieldName.WORKSPACE_ID,
|
||||
workspaceId,
|
||||
FieldName.FLOW_NAME,
|
||||
AnalyticsEvents.GIT_DESERIALIZE_APP_RESOURCES_FROM_FILE.getEventName());
|
||||
|
||||
return analyticsService
|
||||
.sendEvent(
|
||||
AnalyticsEvents.UNIT_EXECUTION_TIME.getEventName(),
|
||||
tuple.getT2().getUsername(),
|
||||
data)
|
||||
.thenReturn(tuple.getT1());
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to reconstruct the application from the local git repo
|
||||
* @param jsonTransformationDTO : DTO which carries the parameter for transformation
|
||||
* @return an instance of an object which extends artifact exchange json.
|
||||
* i.e. Application Json, Package Json
|
||||
*/
|
||||
public Mono<? extends ArtifactExchangeJson> constructArtifactExchangeJsonFromGitRepository(
|
||||
ArtifactJsonTransformationDTO jsonTransformationDTO) {
|
||||
ArtifactType artifactType = jsonTransformationDTO.getArtifactType();
|
||||
ArtifactGitFileUtils<?> artifactGitFileUtils = getArtifactBasedFileHelper(artifactType);
|
||||
|
||||
// Type is not required as checkout happens in similar fashion
|
||||
String refName = jsonTransformationDTO.getRefName();
|
||||
String workspaceId = jsonTransformationDTO.getWorkspaceId();
|
||||
String baseArtifactId = jsonTransformationDTO.getBaseArtifactId();
|
||||
String repoName = jsonTransformationDTO.getRepoName();
|
||||
Path repoSuffixPath = artifactGitFileUtils.getRepoSuffixPath(workspaceId, baseArtifactId, repoName);
|
||||
|
||||
Mono<GitResourceMap> gitResourceMapMono = fileUtils.constructGitResourceMapFromGitRepo(repoSuffixPath, refName);
|
||||
|
||||
return gitResourceMapMono.flatMap(gitResourceMap -> {
|
||||
ArtifactExchangeJson artifactExchangeJson = createArtifactExchangeJson(gitResourceMap, artifactType);
|
||||
copyMetadataToArtifactExchangeJson(gitResourceMap, artifactExchangeJson);
|
||||
return artifactGitFileUtils.performJsonMigration(jsonTransformationDTO, artifactExchangeJson);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* This method copies the metadata from git resource map to artifactExchangeJson
|
||||
* @param gitResourceMap : git resource map generated from file system
|
||||
* @param artifactExchangeJson : artifact json constructed from git resource map
|
||||
*/
|
||||
protected void copyMetadataToArtifactExchangeJson(
|
||||
GitResourceMap gitResourceMap, ArtifactExchangeJson artifactExchangeJson) {
|
||||
GitResourceIdentity metadataIdentity =
|
||||
new GitResourceIdentity(GitResourceType.ROOT_CONFIG, METADATA + JSON_EXTENSION, "");
|
||||
Object metadata = gitResourceMap.getGitResourceMap().get(metadataIdentity);
|
||||
|
||||
Gson gson = new Gson();
|
||||
JsonObject metadataJsonObject = gson.toJsonTree(metadata, Object.class).getAsJsonObject();
|
||||
|
||||
Integer serverSchemaVersion = getServerSchemaVersion(metadataJsonObject);
|
||||
Integer clientSchemaVersion = getClientSchemaVersion(metadataJsonObject);
|
||||
|
||||
artifactExchangeJson.setServerSchemaVersion(serverSchemaVersion);
|
||||
artifactExchangeJson.setClientSchemaVersion(clientSchemaVersion);
|
||||
}
|
||||
|
||||
public boolean isJsonTransformationDTOValid(ArtifactJsonTransformationDTO jsonTransformationDTO) {
|
||||
return jsonTransformationDTO.getArtifactType() != null
|
||||
&& hasText(jsonTransformationDTO.getWorkspaceId())
|
||||
&& hasText(jsonTransformationDTO.getBaseArtifactId())
|
||||
&& hasText(jsonTransformationDTO.getRefName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to reconstruct the application from the local git repo
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.appsmith.server.migrations;
|
||||
|
||||
import com.appsmith.external.git.constants.ce.RefType;
|
||||
import com.appsmith.server.constants.ArtifactType;
|
||||
import com.appsmith.server.dtos.ApplicationJson;
|
||||
import com.appsmith.server.dtos.ArtifactExchangeJson;
|
||||
|
|
@ -41,22 +42,23 @@ public class JsonSchemaMigration {
|
|||
* @param artifactExchangeJson The artifact to be imported.
|
||||
* @param baseArtifactId The base application ID to which it's being imported,
|
||||
* if it's a Git-connected artifact; otherwise, null.
|
||||
* @param branchName The branch name of the artifact being imported,
|
||||
* @param refName The ref name of the artifact being imported,
|
||||
* if it's a Git-connected application; otherwise, null.
|
||||
* @param refType Type of the reference i.e. branch, tag.
|
||||
*/
|
||||
public Mono<? extends ArtifactExchangeJson> migrateArtifactExchangeJsonToLatestSchema(
|
||||
ArtifactExchangeJson artifactExchangeJson, String baseArtifactId, String branchName) {
|
||||
ArtifactExchangeJson artifactExchangeJson, String baseArtifactId, String refName, RefType refType) {
|
||||
|
||||
if (ArtifactType.APPLICATION.equals(artifactExchangeJson.getArtifactJsonType())) {
|
||||
return migrateApplicationJsonToLatestSchema(
|
||||
(ApplicationJson) artifactExchangeJson, baseArtifactId, branchName);
|
||||
(ApplicationJson) artifactExchangeJson, baseArtifactId, refName, refType);
|
||||
}
|
||||
|
||||
return Mono.fromCallable(() -> artifactExchangeJson);
|
||||
}
|
||||
|
||||
public Mono<ApplicationJson> migrateApplicationJsonToLatestSchema(
|
||||
ApplicationJson applicationJson, String baseApplicationId, String branchName) {
|
||||
ApplicationJson applicationJson, String baseApplicationId, String refName, RefType refType) {
|
||||
return Mono.fromCallable(() -> {
|
||||
setSchemaVersions(applicationJson);
|
||||
return applicationJson;
|
||||
|
|
@ -66,7 +68,7 @@ public class JsonSchemaMigration {
|
|||
return Mono.empty();
|
||||
}
|
||||
|
||||
return migrateServerSchema(applicationJson, baseApplicationId, branchName);
|
||||
return migrateServerSchema(applicationJson, baseApplicationId, refName);
|
||||
})
|
||||
.switchIfEmpty(Mono.error(new AppsmithException(AppsmithError.INCOMPATIBLE_IMPORTED_JSON)));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.appsmith.external.constants.ActionCreationSourceTypeEnum;
|
|||
import com.appsmith.external.constants.AnalyticsEvents;
|
||||
import com.appsmith.external.converters.HttpMethodConverter;
|
||||
import com.appsmith.external.converters.ISOStringToInstantConverter;
|
||||
import com.appsmith.external.git.constants.ce.RefType;
|
||||
import com.appsmith.external.helpers.AppsmithBeanUtils;
|
||||
import com.appsmith.external.models.ActionConfiguration;
|
||||
import com.appsmith.external.models.ActionDTO;
|
||||
|
|
@ -250,8 +251,8 @@ public class CreateDBTablePageSolutionCEImpl implements CreateDBTablePageSolutio
|
|||
return applicationJson;
|
||||
})
|
||||
.subscribeOn(Schedulers.boundedElastic())
|
||||
.flatMap(applicationJson ->
|
||||
jsonSchemaMigration.migrateApplicationJsonToLatestSchema(applicationJson, null, null));
|
||||
.flatMap(applicationJson -> jsonSchemaMigration.migrateApplicationJsonToLatestSchema(
|
||||
applicationJson, null, null, RefType.branch));
|
||||
|
||||
return datasourceStorageMono
|
||||
.zipWhen(datasourceStorage -> Mono.zip(
|
||||
|
|
|
|||
|
|
@ -292,8 +292,8 @@ public class CommonGitServiceCETest {
|
|||
|
||||
return stringifiedFile
|
||||
.map(data -> gson.fromJson(data, ApplicationJson.class))
|
||||
.flatMap(applicationJson ->
|
||||
jsonSchemaMigration.migrateArtifactExchangeJsonToLatestSchema(applicationJson, null, null))
|
||||
.flatMap(applicationJson -> jsonSchemaMigration.migrateArtifactExchangeJsonToLatestSchema(
|
||||
applicationJson, null, null, null))
|
||||
.map(artifactExchangeJson -> (ApplicationJson) artifactExchangeJson);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.appsmith.server.git.autocommit;
|
|||
import com.appsmith.external.dtos.GitLogDTO;
|
||||
import com.appsmith.external.git.FileInterface;
|
||||
import com.appsmith.external.git.GitExecutor;
|
||||
import com.appsmith.external.git.constants.ce.RefType;
|
||||
import com.appsmith.external.helpers.AppsmithBeanUtils;
|
||||
import com.appsmith.external.models.ApplicationGitReference;
|
||||
import com.appsmith.server.configurations.ProjectProperties;
|
||||
|
|
@ -435,7 +436,7 @@ public class AutoCommitEventHandlerImplTest {
|
|||
doReturn(Mono.just(applicationJson1))
|
||||
.when(jsonSchemaMigration)
|
||||
.migrateApplicationJsonToLatestSchema(
|
||||
Mockito.eq(applicationJson), Mockito.anyString(), Mockito.anyString());
|
||||
Mockito.eq(applicationJson), Mockito.anyString(), Mockito.anyString(), any(RefType.class));
|
||||
|
||||
doReturn(Mono.just("success"))
|
||||
.when(gitExecutor)
|
||||
|
|
@ -514,7 +515,8 @@ public class AutoCommitEventHandlerImplTest {
|
|||
|
||||
doReturn(Mono.just(applicationJson1))
|
||||
.when(jsonSchemaMigration)
|
||||
.migrateApplicationJsonToLatestSchema(any(), Mockito.anyString(), Mockito.anyString());
|
||||
.migrateApplicationJsonToLatestSchema(
|
||||
any(), Mockito.anyString(), Mockito.anyString(), any(RefType.class));
|
||||
|
||||
gitFileSystemTestHelper.setupGitRepository(autoCommitEvent, applicationJson);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.appsmith.server.git.autocommit;
|
|||
|
||||
import com.appsmith.external.dtos.GitLogDTO;
|
||||
import com.appsmith.external.git.GitExecutor;
|
||||
import com.appsmith.external.git.constants.ce.RefType;
|
||||
import com.appsmith.external.helpers.AppsmithBeanUtils;
|
||||
import com.appsmith.server.acl.AclPermission;
|
||||
import com.appsmith.server.applications.base.ApplicationService;
|
||||
|
|
@ -255,7 +256,7 @@ public class AutoCommitServiceTest {
|
|||
doReturn(Mono.just(applicationJson1))
|
||||
.when(jsonSchemaMigration)
|
||||
.migrateApplicationJsonToLatestSchema(
|
||||
any(ApplicationJson.class), Mockito.anyString(), Mockito.anyString());
|
||||
any(ApplicationJson.class), Mockito.anyString(), Mockito.anyString(), any(RefType.class));
|
||||
|
||||
gitFileSystemTestHelper.setupGitRepository(
|
||||
WORKSPACE_ID, DEFAULT_APP_ID, BRANCH_NAME, REPO_NAME, applicationJson);
|
||||
|
|
@ -544,7 +545,7 @@ public class AutoCommitServiceTest {
|
|||
doReturn(Mono.just(applicationJson1))
|
||||
.when(jsonSchemaMigration)
|
||||
.migrateApplicationJsonToLatestSchema(
|
||||
any(ApplicationJson.class), Mockito.anyString(), Mockito.anyString());
|
||||
any(ApplicationJson.class), Mockito.anyString(), Mockito.anyString(), any(RefType.class));
|
||||
|
||||
gitFileSystemTestHelper.setupGitRepository(
|
||||
WORKSPACE_ID, DEFAULT_APP_ID, BRANCH_NAME, REPO_NAME, applicationJson);
|
||||
|
|
@ -618,7 +619,7 @@ public class AutoCommitServiceTest {
|
|||
doReturn(Mono.just(applicationJson1))
|
||||
.when(jsonSchemaMigration)
|
||||
.migrateApplicationJsonToLatestSchema(
|
||||
any(ApplicationJson.class), Mockito.anyString(), Mockito.anyString());
|
||||
any(ApplicationJson.class), Mockito.anyString(), Mockito.anyString(), any(RefType.class));
|
||||
|
||||
gitFileSystemTestHelper.setupGitRepository(
|
||||
WORKSPACE_ID, DEFAULT_APP_ID, BRANCH_NAME, REPO_NAME, applicationJson);
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ public class GitCommitTests {
|
|||
|
||||
Mockito.doReturn(Mono.just(Paths.get("")))
|
||||
.when(commonGitFileUtils)
|
||||
.saveArtifactToLocalRepoWithAnalytics(any(Path.class), any(), Mockito.anyString());
|
||||
.saveArtifactToLocalRepoNew(any(Path.class), any(), Mockito.anyString());
|
||||
Mockito.doReturn(Mono.error(new EmptyCommitException("nothing to commit")))
|
||||
.when(fsGitHandler)
|
||||
.commitArtifact(
|
||||
|
|
@ -136,7 +136,7 @@ public class GitCommitTests {
|
|||
.initializeReadme(any(Path.class), Mockito.anyString(), Mockito.anyString());
|
||||
Mockito.doReturn(Mono.just(Paths.get("path")))
|
||||
.when(commonGitFileUtils)
|
||||
.saveArtifactToLocalRepoWithAnalytics(any(Path.class), any(), Mockito.anyString());
|
||||
.saveArtifactToLocalRepoNew(any(Path.class), any(), Mockito.anyString());
|
||||
|
||||
Application testApplication = new Application();
|
||||
testApplication.setName(name);
|
||||
|
|
@ -167,7 +167,7 @@ public class GitCommitTests {
|
|||
gitConnectDTO.setGitProfile(gitProfile);
|
||||
return centralGitService
|
||||
.connectArtifactToGit(
|
||||
application1.getId(), gitConnectDTO, "baseUrl", ArtifactType.APPLICATION, GitType.FILE_SYSTEM)
|
||||
application1.getId(), ArtifactType.APPLICATION, gitConnectDTO, "baseUrl", GitType.FILE_SYSTEM)
|
||||
.map(artifact -> (Application) artifact)
|
||||
.block();
|
||||
}
|
||||
|
|
@ -225,7 +225,7 @@ public class GitCommitTests {
|
|||
|
||||
Mockito.doReturn(Mono.error(new RepositoryNotFoundException(AppsmithError.REPOSITORY_NOT_FOUND.getMessage())))
|
||||
.when(commonGitFileUtils)
|
||||
.saveArtifactToLocalRepoWithAnalytics(any(Path.class), any(), Mockito.anyString());
|
||||
.saveArtifactToLocalRepoNew(any(Path.class), any(), Mockito.anyString());
|
||||
|
||||
StepVerifier.create(commitMono)
|
||||
.expectErrorMatches(throwable -> throwable instanceof AppsmithException
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ public class GitConnectTests {
|
|||
gitConnectDTO.setRemoteUrl(null);
|
||||
gitConnectDTO.setGitProfile(new GitProfile());
|
||||
Mono<Application> applicationMono = centralGitService
|
||||
.connectArtifactToGit("testID", gitConnectDTO, "baseUrl", ArtifactType.APPLICATION, GitType.FILE_SYSTEM)
|
||||
.connectArtifactToGit("testID", ArtifactType.APPLICATION, gitConnectDTO, "baseUrl", GitType.FILE_SYSTEM)
|
||||
.map(artifact -> (Application) artifact);
|
||||
|
||||
StepVerifier.create(applicationMono)
|
||||
|
|
@ -108,7 +108,7 @@ public class GitConnectTests {
|
|||
gitConnectDTO.setGitProfile(new GitProfile());
|
||||
|
||||
Mono<Application> applicationMono = centralGitService
|
||||
.connectArtifactToGit("testID", gitConnectDTO, null, ArtifactType.APPLICATION, GitType.FILE_SYSTEM)
|
||||
.connectArtifactToGit("testID", ArtifactType.APPLICATION, gitConnectDTO, null, GitType.FILE_SYSTEM)
|
||||
.map(artifact -> (Application) artifact);
|
||||
|
||||
StepVerifier.create(applicationMono)
|
||||
|
|
@ -151,7 +151,7 @@ public class GitConnectTests {
|
|||
gitConnectDTO.setGitProfile(gitProfile);
|
||||
Mono<Application> applicationMono = centralGitService
|
||||
.connectArtifactToGit(
|
||||
application.getId(), gitConnectDTO, "baseUrl", ArtifactType.APPLICATION, GitType.FILE_SYSTEM)
|
||||
application.getId(), ArtifactType.APPLICATION, gitConnectDTO, "baseUrl", GitType.FILE_SYSTEM)
|
||||
.map(artifact -> (Application) artifact);
|
||||
|
||||
StepVerifier.create(applicationMono)
|
||||
|
|
@ -171,7 +171,7 @@ public class GitConnectTests {
|
|||
gitConnectDTO.setGitProfile(new GitProfile());
|
||||
Mono<Application> applicationMono = centralGitService
|
||||
.connectArtifactToGit(
|
||||
application.getId(), gitConnectDTO, "baseUrl", ArtifactType.APPLICATION, GitType.FILE_SYSTEM)
|
||||
application.getId(), ArtifactType.APPLICATION, gitConnectDTO, "baseUrl", GitType.FILE_SYSTEM)
|
||||
.map(artifact -> (Application) artifact);
|
||||
|
||||
StepVerifier.create(applicationMono)
|
||||
|
|
@ -251,7 +251,7 @@ public class GitConnectTests {
|
|||
|
||||
Mono<Application> applicationMono = centralGitService
|
||||
.connectArtifactToGit(
|
||||
application1.getId(), gitConnectDTO, "baseUrl", ArtifactType.APPLICATION, GitType.FILE_SYSTEM)
|
||||
application1.getId(), ArtifactType.APPLICATION, gitConnectDTO, "baseUrl", GitType.FILE_SYSTEM)
|
||||
.map(artifact -> (Application) artifact);
|
||||
|
||||
StepVerifier.create(applicationMono)
|
||||
|
|
@ -289,7 +289,7 @@ public class GitConnectTests {
|
|||
Mockito.anyString());
|
||||
Mockito.doReturn(Mono.just(Paths.get("")))
|
||||
.when(commonGitFileUtils)
|
||||
.saveArtifactToLocalRepoWithAnalytics(any(Path.class), any(), Mockito.anyString());
|
||||
.saveArtifactToLocalRepoNew(any(Path.class), any(), Mockito.anyString());
|
||||
Mockito.doReturn(Mono.just(true)).when(commonGitFileUtils).checkIfDirectoryIsEmpty(any(Path.class));
|
||||
Mockito.doReturn(Mono.just(Paths.get("textPath")))
|
||||
.when(commonGitFileUtils)
|
||||
|
|
@ -325,7 +325,7 @@ public class GitConnectTests {
|
|||
gitConnectDTO.setGitProfile(gitProfile);
|
||||
Mono<Application> applicationMono = centralGitService
|
||||
.connectArtifactToGit(
|
||||
application1.getId(), gitConnectDTO, "baseUrl", ArtifactType.APPLICATION, GitType.FILE_SYSTEM)
|
||||
application1.getId(), ArtifactType.APPLICATION, gitConnectDTO, "baseUrl", GitType.FILE_SYSTEM)
|
||||
.map(artifact -> (Application) artifact);
|
||||
|
||||
StepVerifier.create(applicationMono)
|
||||
|
|
@ -375,7 +375,7 @@ public class GitConnectTests {
|
|||
gitConnectDTO.setGitProfile(gitProfile);
|
||||
Mono<Application> applicationMono = centralGitService
|
||||
.connectArtifactToGit(
|
||||
application1.getId(), gitConnectDTO, "baseUrl", ArtifactType.APPLICATION, GitType.FILE_SYSTEM)
|
||||
application1.getId(), ArtifactType.APPLICATION, gitConnectDTO, "baseUrl", GitType.FILE_SYSTEM)
|
||||
.map(artifact -> (Application) artifact);
|
||||
|
||||
StepVerifier.create(applicationMono)
|
||||
|
|
@ -421,7 +421,7 @@ public class GitConnectTests {
|
|||
gitConnectDTO.setGitProfile(gitProfile);
|
||||
Mono<Application> applicationMono = centralGitService
|
||||
.connectArtifactToGit(
|
||||
application1.getId(), gitConnectDTO, "baseUrl", ArtifactType.APPLICATION, GitType.FILE_SYSTEM)
|
||||
application1.getId(), ArtifactType.APPLICATION, gitConnectDTO, "baseUrl", GitType.FILE_SYSTEM)
|
||||
.map(artifact -> (Application) artifact);
|
||||
|
||||
StepVerifier.create(applicationMono)
|
||||
|
|
@ -470,7 +470,7 @@ public class GitConnectTests {
|
|||
gitConnectDTO.setGitProfile(gitProfile);
|
||||
Mono<Application> applicationMono = centralGitService
|
||||
.connectArtifactToGit(
|
||||
application1.getId(), gitConnectDTO, "baseUrl", ArtifactType.APPLICATION, GitType.FILE_SYSTEM)
|
||||
application1.getId(), ArtifactType.APPLICATION, gitConnectDTO, "baseUrl", GitType.FILE_SYSTEM)
|
||||
.map(artifact -> (Application) artifact);
|
||||
|
||||
StepVerifier.create(applicationMono)
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ public class GitDiscardTests {
|
|||
.initializeReadme(any(Path.class), Mockito.anyString(), Mockito.anyString());
|
||||
Mockito.doReturn(Mono.just(Paths.get("path")))
|
||||
.when(commonGitFileUtils)
|
||||
.saveArtifactToLocalRepoWithAnalytics(any(Path.class), any(), Mockito.anyString());
|
||||
.saveArtifactToLocalRepoNew(any(Path.class), any(), Mockito.anyString());
|
||||
|
||||
Application testApplication = new Application();
|
||||
testApplication.setName(name);
|
||||
|
|
@ -151,7 +151,7 @@ public class GitDiscardTests {
|
|||
gitConnectDTO.setGitProfile(gitProfile);
|
||||
return centralGitService
|
||||
.connectArtifactToGit(
|
||||
application1.getId(), gitConnectDTO, "baseUrl", ArtifactType.APPLICATION, GitType.FILE_SYSTEM)
|
||||
application1.getId(), ArtifactType.APPLICATION, gitConnectDTO, "baseUrl", GitType.FILE_SYSTEM)
|
||||
.map(artifact -> (Application) artifact)
|
||||
.block();
|
||||
}
|
||||
|
|
@ -167,7 +167,7 @@ public class GitDiscardTests {
|
|||
ArtifactExchangeJson artifactExchangeJson =
|
||||
objectMapper.copy().disable(MapperFeature.USE_ANNOTATIONS).readValue(artifactJson, exchangeJsonType);
|
||||
|
||||
return jsonSchemaMigration.migrateArtifactExchangeJsonToLatestSchema(artifactExchangeJson, null, null);
|
||||
return jsonSchemaMigration.migrateArtifactExchangeJsonToLatestSchema(artifactExchangeJson, null, null, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -198,7 +198,7 @@ public class GitDiscardTests {
|
|||
|
||||
Mockito.doReturn(Mono.just(Paths.get("path")))
|
||||
.when(commonGitFileUtils)
|
||||
.saveArtifactToLocalRepoWithAnalytics(any(Path.class), any(), Mockito.anyString());
|
||||
.saveArtifactToLocalRepoNew(any(Path.class), any(), Mockito.anyString());
|
||||
Mockito.doReturn(Mono.just(artifactExchangeJson))
|
||||
.when(gitHandlingService)
|
||||
.recreateArtifactJsonFromLastCommit(Mockito.any());
|
||||
|
|
@ -243,7 +243,7 @@ public class GitDiscardTests {
|
|||
|
||||
Mockito.doReturn(Mono.just(Paths.get("path")))
|
||||
.when(commonGitFileUtils)
|
||||
.saveArtifactToLocalRepoWithAnalytics(any(Path.class), any(), Mockito.anyString());
|
||||
.saveArtifactToLocalRepoNew(any(Path.class), any(), Mockito.anyString());
|
||||
Mockito.doReturn(Mono.just(artifactExchangeJson))
|
||||
.when(gitHandlingService)
|
||||
.recreateArtifactJsonFromLastCommit(Mockito.any());
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ public class ExchangeJsonConversionTests {
|
|||
ArtifactExchangeJson artifactExchangeJson =
|
||||
objectMapper.copy().disable(MapperFeature.USE_ANNOTATIONS).readValue(artifactJson, exchangeJsonType);
|
||||
|
||||
return jsonSchemaMigration.migrateArtifactExchangeJsonToLatestSchema(artifactExchangeJson, null, null);
|
||||
return jsonSchemaMigration.migrateArtifactExchangeJsonToLatestSchema(artifactExchangeJson, null, null, null);
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
|
|
|
|||
|
|
@ -84,8 +84,8 @@ public class GitFileUtilsTest {
|
|||
.map(data -> {
|
||||
return gson.fromJson(data, ApplicationJson.class);
|
||||
})
|
||||
.flatMap(applicationJson ->
|
||||
jsonSchemaMigration.migrateArtifactExchangeJsonToLatestSchema(applicationJson, null, null))
|
||||
.flatMap(applicationJson -> jsonSchemaMigration.migrateArtifactExchangeJsonToLatestSchema(
|
||||
applicationJson, null, null, null))
|
||||
.map(artifactExchangeJson -> (ApplicationJson) artifactExchangeJson);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -361,8 +361,8 @@ public class ImportServiceTests {
|
|||
.map(data -> {
|
||||
return gson.fromJson(data, ApplicationJson.class);
|
||||
})
|
||||
.flatMap(applicationJson ->
|
||||
jsonSchemaMigration.migrateArtifactExchangeJsonToLatestSchema(applicationJson, null, null))
|
||||
.flatMap(applicationJson -> jsonSchemaMigration.migrateArtifactExchangeJsonToLatestSchema(
|
||||
applicationJson, null, null, null))
|
||||
.map(artifactExchangeJson -> (ApplicationJson) artifactExchangeJson);
|
||||
}
|
||||
|
||||
|
|
@ -2724,7 +2724,8 @@ public class ImportServiceTests {
|
|||
.flatMap(applicationJson -> {
|
||||
ApplicationJson applicationJson1 = new ApplicationJson();
|
||||
AppsmithBeanUtils.copyNestedNonNullProperties(applicationJson, applicationJson1);
|
||||
return jsonSchemaMigration.migrateArtifactExchangeJsonToLatestSchema(applicationJson1, null, null);
|
||||
return jsonSchemaMigration.migrateArtifactExchangeJsonToLatestSchema(
|
||||
applicationJson1, null, null, null);
|
||||
})
|
||||
.map(applicationJson -> (ApplicationJson) applicationJson);
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ public class JsonSchemaMigrationTest {
|
|||
gitFileSystemTestHelper.getApplicationJson(this.getClass().getResource("application.json"));
|
||||
|
||||
ArtifactExchangeJson artifactExchangeJson = jsonSchemaMigration
|
||||
.migrateArtifactExchangeJsonToLatestSchema(applicationJson, null, null)
|
||||
.migrateArtifactExchangeJsonToLatestSchema(applicationJson, null, null, null)
|
||||
.block();
|
||||
assertThat(artifactExchangeJson.getServerSchemaVersion()).isEqualTo(jsonSchemaVersions.getServerVersion());
|
||||
assertThat(artifactExchangeJson.getClientSchemaVersion()).isEqualTo(jsonSchemaVersions.getClientVersion());
|
||||
|
|
@ -55,7 +55,7 @@ public class JsonSchemaMigrationTest {
|
|||
gitFileSystemTestHelper.getApplicationJson(this.getClass().getResource("application.json"));
|
||||
|
||||
Mono<ApplicationJson> applicationJsonMono =
|
||||
jsonSchemaMigration.migrateApplicationJsonToLatestSchema(applicationJson, null, null);
|
||||
jsonSchemaMigration.migrateApplicationJsonToLatestSchema(applicationJson, null, null, null);
|
||||
StepVerifier.create(applicationJsonMono)
|
||||
.assertNext(appJson -> {
|
||||
assertThat(appJson.getServerSchemaVersion()).isEqualTo(jsonSchemaVersions.getServerVersion());
|
||||
|
|
|
|||
|
|
@ -130,8 +130,8 @@ public class ImportApplicationTransactionServiceTest {
|
|||
.map(data -> {
|
||||
return gson.fromJson(data, ApplicationJson.class);
|
||||
})
|
||||
.flatMap(applicationJson ->
|
||||
jsonSchemaMigration.migrateArtifactExchangeJsonToLatestSchema(applicationJson, null, null))
|
||||
.flatMap(applicationJson -> jsonSchemaMigration.migrateArtifactExchangeJsonToLatestSchema(
|
||||
applicationJson, null, null, null))
|
||||
.map(artifactExchangeJson -> (ApplicationJson) artifactExchangeJson);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -112,6 +112,6 @@ public class ArtifactBuilderExtension implements AfterEachCallback, BeforeEachCa
|
|||
ArtifactExchangeJson artifactExchangeJson =
|
||||
objectMapper.copy().disable(MapperFeature.USE_ANNOTATIONS).readValue(artifactJson, exchangeJsonType);
|
||||
|
||||
return jsonSchemaMigration.migrateArtifactExchangeJsonToLatestSchema(artifactExchangeJson, null, null);
|
||||
return jsonSchemaMigration.migrateArtifactExchangeJsonToLatestSchema(artifactExchangeJson, null, null, null);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user