Skip to content

Commit

Permalink
added changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sondermanish committed Dec 17, 2024
1 parent 5cf5026 commit 03a3843
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public class FieldNameCE {
public static final String IS_REQUIRED = "isRequired";
public static final String UNUSED_DATASOURCE = "UNUSED_DATASOURCE";
public static final String BRANCH_NAME = "branchName";
public static final String REF_TYPE = "refType";
public static final String REF_NAME = "refName";
public static final String SOURCE_BRANCH = "sourceBranch";
public static final String DESTINATION_BRANCH = "destinationBranch";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.appsmith.server.git.central;

import com.appsmith.external.dtos.GitRefDTO;
import com.appsmith.external.dtos.GitStatusDTO;
import com.appsmith.external.git.constants.ce.RefType;
import com.appsmith.git.dto.CommitDTO;
Expand Down Expand Up @@ -45,4 +46,7 @@ Mono<? extends Artifact> checkoutReference(
ArtifactType artifactType,
GitType gitType,
RefType refType);

Mono<? extends Artifact> createReference(
String referencedArtifactId, GitRefDTO refDTO, ArtifactType artifactType, GitType gitType);
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@
import static com.appsmith.server.constants.FieldName.BRANCH_NAME;
import static com.appsmith.server.constants.FieldName.DEFAULT;
import static com.appsmith.server.constants.SerialiseArtifactObjective.VERSION_CONTROL;
import static com.appsmith.server.constants.ce.FieldNameCE.REF_NAME;
import static com.appsmith.server.constants.ce.FieldNameCE.REF_TYPE;
import static java.lang.Boolean.FALSE;
import static java.lang.Boolean.TRUE;
import static org.springframework.util.StringUtils.hasText;
Expand Down Expand Up @@ -439,21 +441,24 @@ protected Mono<? extends Artifact> checkoutRemoteBranch(Artifact baseArtifact, S
return null;
}

public Mono<? extends Artifact> checkoutReference(
String referencedArtifactId,
GitRefDTO refDTO,
ArtifactType artifactType,
GitType gitType,
RefType refType) {
@Override
public Mono<? extends Artifact> createReference(
String referencedArtifactId, GitRefDTO refDTO, ArtifactType artifactType, GitType gitType) {

/*
1. Check if the src artifact is available and user have sufficient permissions
2. Create and checkout to requested branch
3. Rehydrate the artifact from source artifact reference
*/

RefType refType = refDTO.getRefType();

if (refDTO.getRefType() == null) {
return Mono.error(new AppsmithException(AppsmithError.INVALID_PARAMETER, REF_TYPE));
}

if (!hasText(refDTO.getRefName()) || refDTO.getRefName().startsWith(ORIGIN)) {
return Mono.error(new AppsmithException(AppsmithError.INVALID_PARAMETER, BRANCH_NAME));
return Mono.error(new AppsmithException(AppsmithError.INVALID_PARAMETER, REF_NAME));
}

GitArtifactHelper<?> gitArtifactHelper = gitArtifactHelperResolver.getArtifactHelper(artifactType);
Expand Down

0 comments on commit 03a3843

Please sign in to comment.