From 910a81a1c156c21b1fc1b24a01efb50a777e49ec Mon Sep 17 00:00:00 2001 From: sondermanish Date: Mon, 3 Feb 2025 12:11:41 +0530 Subject: [PATCH 1/5] added changes --- .../git/handler/ce/FSGitHandlerCEImpl.java | 77 ++- .../git/constants/ce/GitConstantsCE.java | 1 + .../external/git/handler/FSGitHandler.java | 13 + .../git/central/CentralGitServiceCE.java | 5 +- .../git/central/CentralGitServiceCEImpl.java | 495 +++++++++--------- .../git/central/GitHandlingServiceCE.java | 2 +- .../GitApplicationControllerCE.java | 18 +- .../controllers/GitArtifactControllerCE.java | 45 ++ .../server/git/fs/GitFSServiceCEImpl.java | 44 +- .../services/ce/FeatureFlagServiceCEImpl.java | 2 + .../git/GitBranchesITWithCentralService.java | 14 +- 11 files changed, 434 insertions(+), 282 deletions(-) diff --git a/app/server/appsmith-git/src/main/java/com/appsmith/git/handler/ce/FSGitHandlerCEImpl.java b/app/server/appsmith-git/src/main/java/com/appsmith/git/handler/ce/FSGitHandlerCEImpl.java index f1992f970c91..3dd0e4970ef5 100644 --- a/app/server/appsmith-git/src/main/java/com/appsmith/git/handler/ce/FSGitHandlerCEImpl.java +++ b/app/server/appsmith-git/src/main/java/com/appsmith/git/handler/ce/FSGitHandlerCEImpl.java @@ -465,6 +465,70 @@ public Mono checkoutToBranch(Path repoSuffix, String branchName) { .subscribeOn(scheduler); } + @Override + public Mono pullArtifactWithoutCheckout( + Path repoSuffix, String remoteUrl, String branchName, String privateKey, String publicKey) + throws IOException { + + TransportConfigCallback transportConfigCallback = new SshTransportConfigCallback(privateKey, publicKey); + return Mono.using( + () -> Git.open(createRepoPath(repoSuffix).toFile()), + git -> Mono.fromCallable(() -> { + log.info( + "{} : Pull changes from remote {} for the branch {}.", + Thread.currentThread().getName(), + remoteUrl, + branchName); + MergeResult mergeResult; + try { + mergeResult = git.pull() + .setRemoteBranchName(branchName) + .setTransportConfigCallback(transportConfigCallback) + .setFastForward(MergeCommand.FastForwardMode.FF) + .call() + .getMergeResult(); + } catch (GitAPIException e) { + throw e; + } + MergeStatusDTO mergeStatus = new MergeStatusDTO(); + Long count = Arrays.stream(mergeResult.getMergedCommits()) + .count(); + if (mergeResult.getMergeStatus().isSuccessful()) { + mergeStatus.setMergeAble(true); + mergeStatus.setStatus(count + " commits merged from origin/" + branchName); + return mergeStatus; + } else { + // If there are conflicts add the conflicting file names to the response + // structure + mergeStatus.setMergeAble(false); + List mergeConflictFiles = new ArrayList<>(); + if (!Optional.ofNullable(mergeResult.getConflicts()) + .isEmpty()) { + mergeConflictFiles.addAll( + mergeResult.getConflicts().keySet()); + } + mergeStatus.setConflictingFiles(mergeConflictFiles); + try { + // On merge conflicts abort the merge => git merge --abort + git.getRepository().writeMergeCommitMsg(null); + git.getRepository().writeMergeHeads(null); + throw new org.eclipse.jgit.errors.CheckoutConflictException( + mergeConflictFiles.toString()); + } catch (IOException e) { + log.debug("Encountered error while aborting merge", e); + throw new org.eclipse.jgit.errors.CheckoutConflictException( + mergeConflictFiles.toString()); + } + } + }) + .onErrorResume(error -> resetToLastCommit(git).flatMap(ignore -> Mono.error(error))) + .timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS)) + .name(GitSpan.FS_PULL) + .tap(Micrometer.observation(observationRegistry)), + Git::close) + .subscribeOn(scheduler); + } + @Override public Mono pullApplication( Path repoSuffix, String remoteUrl, String branchName, String privateKey, String publicKey) @@ -951,7 +1015,14 @@ public Mono fetchRemote( git -> Mono.fromCallable(() -> { TransportConfigCallback config = new SshTransportConfigCallback(privateKey, publicKey); - String fetchMessages; + + if (TRUE.equals(fetchRemoteDTO.getIsFetchAll())) { + return git.fetch() + .setRemoveDeletedRefs(true) + .setTransportConfigCallback(config) + .call() + .getMessages(); + } List refNames = fetchRemoteDTO.getRefNames(); RefType refType = fetchRemoteDTO.getRefType(); @@ -973,7 +1044,7 @@ public Mono fetchRemote( } } - fetchMessages = git.fetch() + return git.fetch() .setRefSpecs(refSpecs.toArray(new RefSpec[0])) .setRemoveDeletedRefs(true) .setTagOpt(TagOpt.NO_TAGS) // no tags would mean that tags are fetched @@ -981,8 +1052,6 @@ public Mono fetchRemote( .setTransportConfigCallback(config) .call() .getMessages(); - - return fetchMessages; }) .onErrorResume(error -> { log.error(error.getMessage()); diff --git a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/ce/GitConstantsCE.java b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/ce/GitConstantsCE.java index 039714e4a3c7..7ca6ac4127bc 100644 --- a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/ce/GitConstantsCE.java +++ b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/ce/GitConstantsCE.java @@ -11,6 +11,7 @@ public class GitConstantsCE { public static final String README_FILE_NAME = "README.md"; + public static final String FIRST_COMMIT = "System added readme file"; public static final String DEFAULT_COMMIT_MESSAGE = "System generated commit, "; public static final String EMPTY_COMMIT_ERROR_MESSAGE = "On current branch nothing to commit, working tree clean"; public static final String MERGE_CONFLICT_BRANCH_NAME = "_mergeConflict"; diff --git a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/handler/FSGitHandler.java b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/handler/FSGitHandler.java index 8ebe59f4c6f2..cd6f503e3605 100644 --- a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/handler/FSGitHandler.java +++ b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/handler/FSGitHandler.java @@ -102,6 +102,19 @@ Mono pushApplication( */ Mono checkoutToBranch(Path repoSuffix, String branchName); + /** + * Pull changes from remote branch and merge the changes + * @param repoSuffix suffixedPath used to generate the base repo path this includes workspaceId, defaultAppId, repoName + * @param remoteUrl ssh url of the git repo(we support cloning via ssh url only with deploy key) + * @param branchName remoteBranchName from which commits will be fetched and merged to the current branch + * @param privateKey generated by us and specific to the defaultApplication + * @param publicKey generated by us and specific to the defaultApplication + * @return success message + */ + Mono pullArtifactWithoutCheckout( + Path repoSuffix, String remoteUrl, String branchName, String privateKey, String publicKey) + throws IOException; + /** * Pull changes from remote branch and merge the changes * @param repoSuffix suffixedPath used to generate the base repo path this includes workspaceId, defaultAppId, repoName diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/git/central/CentralGitServiceCE.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/git/central/CentralGitServiceCE.java index 752dced6f13b..58696d9cf5af 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/git/central/CentralGitServiceCE.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/git/central/CentralGitServiceCE.java @@ -1,6 +1,5 @@ package com.appsmith.server.git.central; -import com.appsmith.external.dtos.GitBranchDTO; import com.appsmith.external.dtos.GitRefDTO; import com.appsmith.external.dtos.GitStatusDTO; import com.appsmith.external.dtos.MergeStatusDTO; @@ -37,7 +36,7 @@ Mono commitArtifact( Mono detachRemote(String branchedArtifactId, ArtifactType artifactType, GitType gitType); - Mono> listBranchForArtifact( + Mono> listBranchForArtifact( String branchedArtifactId, ArtifactType artifactType, Boolean pruneBranches, GitType gitType); Mono fetchRemoteChanges( @@ -71,7 +70,7 @@ Mono createReference( String referencedArtifactId, ArtifactType artifactType, GitRefDTO refDTO, GitType gitType); Mono deleteGitReference( - String baseArtifactId, ArtifactType artifactType, GitRefDTO gitRefDTO, GitType gitType); + String baseArtifactId, ArtifactType artifactType, String refName, RefType refType, GitType gitType); Mono> updateProtectedBranches( String baseArtifactId, ArtifactType artifactType, List branchNames); diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/git/central/CentralGitServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/git/central/CentralGitServiceCEImpl.java index c4d576b3c6ad..87617432cd8f 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/git/central/CentralGitServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/git/central/CentralGitServiceCEImpl.java @@ -7,8 +7,8 @@ import com.appsmith.external.dtos.GitStatusDTO; import com.appsmith.external.dtos.MergeStatusDTO; import com.appsmith.external.git.constants.GitConstants; +import com.appsmith.external.git.constants.GitConstants.GitCommandConstants; import com.appsmith.external.git.constants.GitSpan; -import com.appsmith.external.git.constants.ce.GitConstantsCE; import com.appsmith.external.git.constants.ce.RefType; import com.appsmith.external.git.dtos.FetchRemoteDTO; import com.appsmith.external.models.Datasource; @@ -428,7 +428,7 @@ protected Mono checkoutReference( jsonTransformationDTO.setBaseArtifactId(baseGitMetadata.getDefaultArtifactId()); jsonTransformationDTO.setRefName(finalRefName); jsonTransformationDTO.setRefType(refType); - jsonTransformationDTO.setArtifactType(baseArtifact.getArtifactType()); + jsonTransformationDTO.setArtifactType(artifactType); jsonTransformationDTO.setRepoName(baseGitMetadata.getRepoName()); if (gitRefDTO.getRefName().startsWith(ORIGIN)) { @@ -446,7 +446,7 @@ protected Mono checkoutReference( return Mono.error(new AppsmithException( AppsmithError.GIT_ACTION_FAILED, - "checkout", + GitCommandConstants.CHECKOUT_BRANCH, gitRefDTO.getRefName() + " already exists in local - " + finalRefName)); }); } else { @@ -637,12 +637,17 @@ protected Mono createReference( GitConstants.GitCommandConstants.CREATE_BRANCH, FALSE); + FetchRemoteDTO fetchRemoteDTO = new FetchRemoteDTO(); + fetchRemoteDTO.setRefType(refType); + fetchRemoteDTO.setIsFetchAll(TRUE); + Mono fetchRemoteMono = - gitHandlingService.fetchRemoteReferences(baseRefTransformationDTO, baseGitAuth, TRUE); + gitHandlingService.fetchRemoteReferences(baseRefTransformationDTO, fetchRemoteDTO, baseGitAuth); Mono createBranchMono = acquireGitLockMono - .flatMap(ignoreLockAcquisition -> fetchRemoteMono.onErrorResume( - error -> Mono.error(new AppsmithException(AppsmithError.GIT_ACTION_FAILED, "fetch", error)))) + .flatMap(ignoreLockAcquisition -> + fetchRemoteMono.onErrorResume(error -> Mono.error(new AppsmithException( + AppsmithError.GIT_ACTION_FAILED, GitCommandConstants.FETCH_REMOTE, error)))) .flatMap(ignoreFetchString -> gitHandlingService .listReferences(createRefTransformationDTO, TRUE) .flatMap(refList -> { @@ -684,7 +689,8 @@ protected Mono createReference( Artifact newRefArtifact = tuple.getT1(); Mono refCreationMono = gitHandlingService - .createGitReference(createRefTransformationDTO, baseGitMetadata, refDTO) + .createGitReference( + baseRefTransformationDTO, createRefTransformationDTO, baseGitMetadata, refDTO) // TODO: this error could be shipped to handling layer as well? .onErrorResume(error -> Mono.error(new AppsmithException( AppsmithError.GIT_ACTION_FAILED, "ref creation preparation", error.getMessage()))); @@ -701,7 +707,7 @@ protected Mono createReference( return gitArtifactHelper.publishArtifactPostRefCreation( importedArtifact, refType, TRUE); }) - // after the branch is created, we need to reset the older branch to the + // after the ref is created, the older ref should be reset to a // clean status, i.e. last commit .flatMap(newImportedArtifact -> discardChanges(sourceArtifact, gitType).thenReturn(newImportedArtifact)); @@ -716,7 +722,10 @@ protected Mono createReference( log.error("An error occurred while creating reference. error {}", error.getMessage()); return gitRedisUtils .releaseFileLock(artifactType, baseArtifactId, TRUE) - .then(Mono.error(new AppsmithException(AppsmithError.GIT_ACTION_FAILED, "checkout"))); + .then(Mono.error(new AppsmithException( + AppsmithError.GIT_ACTION_FAILED, + GitCommandConstants.CREATE_BRANCH, + error.getMessage()))); }) .name(GitSpan.OPS_CREATE_BRANCH) .tap(Micrometer.observation(observationRegistry)); @@ -741,10 +750,7 @@ protected Mono isValidationForRefCreationComplete( @Override public Mono deleteGitReference( - String baseArtifactId, ArtifactType artifactType, GitRefDTO gitRefDTO, GitType gitType) { - - String refName = gitRefDTO.getRefName(); - RefType refType = gitRefDTO.getRefType(); + String baseArtifactId, ArtifactType artifactType, String refName, RefType refType, GitType gitType) { if (refType == null) { return Mono.error(new AppsmithException(AppsmithError.INVALID_PARAMETER, REF_TYPE)); @@ -1073,14 +1079,13 @@ public Mono connectArtifactToGit( jsonTransformationDTO.setArtifactType(artifactType); jsonTransformationDTO.setRepoName(repoName); - final String README_FILE_NAME = GitConstantsCE.README_FILE_NAME; + final String README_FILE_NAME = GitConstants.README_FILE_NAME; Mono readMeIntialisationMono = gitHandlingService.initialiseReadMe( jsonTransformationDTO, artifact, README_FILE_NAME, originHeader); return Mono.zip(readMeIntialisationMono, gitUserMono) .flatMap(tuple2 -> { - String commitMessage = - DEFAULT_COMMIT_MESSAGE + GitDefaultCommitMessage.CONNECT_FLOW.getReason(); + String commitMessage = GitConstants.FIRST_COMMIT; GitUser author = tuple2.getT2(); CommitDTO commitDTO = new CommitDTO(); commitDTO.setAuthor(author); @@ -1533,78 +1538,88 @@ protected Mono getStatus( boolean compareRemote, GitType gitType) { - ArtifactType artifactType = baseArtifact.getArtifactType(); GitHandlingService gitHandlingService = gitHandlingServiceResolver.getGitHandlingService(gitType); - GitArtifactMetadata baseGitMetadata = baseArtifact.getGitArtifactMetadata(); - final String baseArtifactId = baseGitMetadata.getDefaultArtifactId(); GitArtifactMetadata branchedGitMetadata = branchedArtifact.getGitArtifactMetadata(); branchedGitMetadata.setGitAuth(baseGitMetadata.getGitAuth()); final String finalBranchName = branchedGitMetadata.getRefName(); + RefType refType = branchedGitMetadata.getRefType(); if (!StringUtils.hasText(finalBranchName)) { return Mono.error(new AppsmithException(AppsmithError.INVALID_PARAMETER, FieldName.BRANCH_NAME)); } - Mono exportedArtifactJsonMono = - exportService.exportByArtifactId(branchedArtifact.getId(), VERSION_CONTROL, artifactType); + ArtifactType artifactType = baseArtifact.getArtifactType(); + final String baseArtifactId = baseGitMetadata.getDefaultArtifactId(); + String workspaceId = baseArtifact.getWorkspaceId(); + String repoName = baseGitMetadata.getRepoName(); - Mono statusMono = exportedArtifactJsonMono - .flatMap(artifactExchangeJson -> { - return gitRedisUtils - .acquireGitLock( - artifactType, baseArtifactId, GitConstants.GitCommandConstants.STATUS, isFileLock) - .thenReturn(artifactExchangeJson); - }) - .flatMap(artifactExchangeJson -> { - ArtifactJsonTransformationDTO jsonTransformationDTO = new ArtifactJsonTransformationDTO(); - jsonTransformationDTO.setRefType(RefType.branch); - jsonTransformationDTO.setWorkspaceId(baseArtifact.getWorkspaceId()); - jsonTransformationDTO.setBaseArtifactId(baseArtifact.getId()); - jsonTransformationDTO.setRepoName( - branchedArtifact.getGitArtifactMetadata().getRepoName()); - jsonTransformationDTO.setArtifactType(artifactExchangeJson.getArtifactJsonType()); - jsonTransformationDTO.setRefName(finalBranchName); + ArtifactJsonTransformationDTO jsonTransformationDTO = + new ArtifactJsonTransformationDTO(workspaceId, baseArtifactId, repoName, artifactType); + jsonTransformationDTO.setRefName(finalBranchName); + jsonTransformationDTO.setRefType(refType); + FetchRemoteDTO fetchRemoteDTO = new FetchRemoteDTO(); + fetchRemoteDTO.setRefNames(List.of(finalBranchName)); + fetchRemoteDTO.setRefType(refType); + fetchRemoteDTO.setIsFetchAll(false); + + Mono exportedArtifactJsonMono = exportService + .exportByArtifactId(branchedArtifact.getId(), VERSION_CONTROL, artifactType) + .zipWhen(exportedArtifactJson -> gitRedisUtils.acquireGitLock( + artifactType, baseArtifactId, GitCommandConstants.STATUS, isFileLock)) + .map(Tuple2::getT1); + + // This block only enters when a redis lock is acquired + Mono lockHandledStatusMono = Mono.usingWhen( + exportedArtifactJsonMono, + artifactExchangeJson -> { Mono prepareForStatus = gitHandlingService.prepareChangesToBeCommitted(jsonTransformationDTO, artifactExchangeJson); - Mono fetchRemoteMono; + + Mono fetchRemoteMono = Mono.just("ignored"); if (compareRemote) { - fetchRemoteMono = Mono.defer( - () -> fetchRemoteChanges(baseArtifact, branchedArtifact, FALSE, gitType, RefType.branch) - .onErrorResume(error -> Mono.error(new AppsmithException( - AppsmithError.GIT_GENERIC_ERROR, error.getMessage())))); - } else { - fetchRemoteMono = Mono.just("ignored"); + if (isBaseGitMetadataInvalid(baseGitMetadata, gitType)) { + return Mono.error(new AppsmithException(AppsmithError.INVALID_GIT_CONFIGURATION)); + } + + fetchRemoteMono = Mono.defer(() -> gitHandlingService + .fetchRemoteReferences( + jsonTransformationDTO, fetchRemoteDTO, baseGitMetadata.getGitAuth()) + .onErrorResume(error -> Mono.error(new AppsmithException( + AppsmithError.GIT_ACTION_FAILED, + GitCommandConstants.FETCH_REMOTE, + error.getMessage())))); } - return Mono.zip(prepareForStatus, fetchRemoteMono).flatMap(tuple2 -> { - return gitHandlingService - .getStatus(jsonTransformationDTO) - .flatMap(gitStatusDTO -> { - return gitRedisUtils - .releaseFileLock(artifactType, baseArtifactId, isFileLock) - .thenReturn(gitStatusDTO); - }); - }); - }) - .onErrorResume(throwable -> { - /* - in case of any error, the global exception handler will release the lock - hence we don't need to do that manually - */ - log.error( - "Error to get status for artifact: {}, branch: {}", - baseArtifactId, - finalBranchName, - throwable); - return Mono.error(new AppsmithException(AppsmithError.GIT_GENERIC_ERROR, throwable.getMessage())); - }); + return Mono.zip(prepareForStatus, fetchRemoteMono) + .then(Mono.defer(() -> gitHandlingService.getStatus(jsonTransformationDTO))) + .onErrorResume(throwable -> { + /* + in case of any error, the global exception handler will release the lock + hence we don't need to do that manually + */ + log.error( + "Error to get status for artifact: {}, branch: {}", + baseArtifactId, + finalBranchName, + throwable); + if (throwable instanceof AppsmithException) { + return Mono.error(throwable); + } - return Mono.zip(statusMono, sessionUserService.getCurrentUser()) + return Mono.error(new AppsmithException( + AppsmithError.GIT_ACTION_FAILED, + GitCommandConstants.STATUS, + throwable.getMessage())); + }); + }, + artifactExchangeJson -> gitRedisUtils.releaseFileLock(artifactType, baseArtifactId, isFileLock)); + + return Mono.zip(lockHandledStatusMono, sessionUserService.getCurrentUser()) .elapsed() .flatMap(objects -> { Long elapsedTime = objects.getT1(); @@ -1661,49 +1676,44 @@ public Mono pullArtifact(String branchedArtifactId, ArtifactType art protected Mono pullArtifact(Artifact baseArtifact, Artifact branchedArtifact, GitType gitType) { GitArtifactMetadata branchedGitMetadata = branchedArtifact.getGitArtifactMetadata(); - Mono statusMono = getStatus(baseArtifact, branchedArtifact, false, true, gitType); ArtifactType artifactType = baseArtifact.getArtifactType(); + String baseArtifactId = branchedGitMetadata.getDefaultArtifactId(); + + Mono lockHandledpullDTOMono = Mono.usingWhen( + gitRedisUtils.acquireGitLock(artifactType, baseArtifactId, GitCommandConstants.PULL, TRUE), + ignoreLock -> { + // TODO: verifying why remote needs to be fetched for status, when only modified is checked + Mono statusMono = + getStatus(baseArtifact, branchedArtifact, false, false, gitType); + + return statusMono.flatMap(gitStatusDTO -> { + // Check if the repo is clean + if (!CollectionUtils.isEmpty(gitStatusDTO.getModified())) { + return Mono.error( + new AppsmithException( + AppsmithError.GIT_ACTION_FAILED, + GitCommandConstants.PULL, + "There are uncommitted changes present in your local. Please commit them first and then try git pull")); + } + return pullAndRehydrateArtifact(baseArtifact, branchedArtifact, gitType) + .onErrorResume(exception -> { + if (exception instanceof AppsmithException) { + return Mono.error(exception); + } - Mono pullDTOMono = gitRedisUtils - .acquireGitLock( - artifactType, - branchedGitMetadata.getDefaultArtifactId(), - GitConstants.GitCommandConstants.PULL, - TRUE) - .then(Mono.defer(() -> statusMono)) - .flatMap(status -> { - // Check if the repo is clean - if (!CollectionUtils.isEmpty(status.getModified())) { - return gitRedisUtils - .releaseFileLock(artifactType, branchedGitMetadata.getDefaultArtifactId(), TRUE) - .then( - Mono.error( - new AppsmithException( - AppsmithError.GIT_ACTION_FAILED, - "pull", - "There are uncommitted changes present in your local. Please commit them first and then try git pull"))); - } - - return pullAndRehydrateArtifact(baseArtifact, branchedArtifact, gitType) - // Release file lock after the pull operation - .flatMap(gitPullDTO -> gitRedisUtils - .releaseFileLock(artifactType, branchedGitMetadata.getDefaultArtifactId(), TRUE) - .then(Mono.just(gitPullDTO))); - }) - .onErrorResume(error -> { - log.error( - "An error occurred while trying to pull the artifact with base id: {} and branchName: {}", - branchedGitMetadata.getDefaultArtifactId(), - branchedGitMetadata.getRefName()); - - return gitRedisUtils - .releaseFileLock(artifactType, branchedGitMetadata.getDefaultArtifactId(), TRUE) - .then(Mono.error(error)); - }) + return Mono.error(new AppsmithException( + AppsmithError.GIT_ACTION_FAILED, + GitCommandConstants.PULL, + exception.getMessage())); + }); + }); + }, + ignoreLock -> gitRedisUtils.releaseFileLock(artifactType, baseArtifactId, TRUE)) .name(GitSpan.OPS_PULL) .tap(Micrometer.observation(observationRegistry)); - return Mono.create(sink -> pullDTOMono.subscribe(sink::success, sink::error, null, sink.currentContext())); + return Mono.create( + sink -> lockHandledpullDTOMono.subscribe(sink::success, sink::error, null, sink.currentContext())); } /** @@ -1740,13 +1750,11 @@ private Mono pullAndRehydrateArtifact( final String repoName = branchedGitMetadata.getRepoName(); final String branchName = branchedGitMetadata.getRefName(); - ArtifactJsonTransformationDTO jsonTransformationDTO = new ArtifactJsonTransformationDTO(); - jsonTransformationDTO.setRepoName(repoName); + ArtifactJsonTransformationDTO jsonTransformationDTO = new ArtifactJsonTransformationDTO( + workspaceId, baseArtifactId, repoName, baseArtifact.getArtifactType()); + jsonTransformationDTO.setRefType(RefType.branch); jsonTransformationDTO.setRefName(branchName); - jsonTransformationDTO.setWorkspaceId(workspaceId); - jsonTransformationDTO.setBaseArtifactId(baseArtifactId); - jsonTransformationDTO.setArtifactType(baseArtifact.getArtifactType()); return Mono.defer(() -> { // Rehydrate the artifact from git system @@ -2013,80 +2021,79 @@ public Mono discardChanges( protected Mono discardChanges(Artifact branchedArtifact, GitType gitType) { ArtifactType artifactType = branchedArtifact.getArtifactType(); - GitArtifactHelper gitArtifactHelper = gitArtifactHelperResolver.getArtifactHelper(artifactType); - GitHandlingService gitHandlingService = gitHandlingServiceResolver.getGitHandlingService(gitType); - GitArtifactMetadata branchedGitData = branchedArtifact.getGitArtifactMetadata(); + if (branchedGitData == null || !hasText(branchedGitData.getDefaultArtifactId())) { return Mono.error(new AppsmithException(AppsmithError.INVALID_GIT_CONFIGURATION, GIT_CONFIG_ERROR)); } - ArtifactJsonTransformationDTO jsonTransformationDTO = new ArtifactJsonTransformationDTO(); - jsonTransformationDTO.setArtifactType(branchedArtifact.getArtifactType()); + GitArtifactHelper gitArtifactHelper = gitArtifactHelperResolver.getArtifactHelper(artifactType); + GitHandlingService gitHandlingService = gitHandlingServiceResolver.getGitHandlingService(gitType); + + final String workspaceId = branchedArtifact.getWorkspaceId(); + final String baseArtifactId = branchedGitData.getDefaultArtifactId(); + final String repoName = branchedGitData.getRepoName(); + final String branchName = branchedGitData.getRefName(); + + ArtifactJsonTransformationDTO jsonTransformationDTO = new ArtifactJsonTransformationDTO( + workspaceId, baseArtifactId, repoName, branchedArtifact.getArtifactType()); + // Because this operation is only valid for branches jsonTransformationDTO.setRefType(RefType.branch); - jsonTransformationDTO.setWorkspaceId(branchedArtifact.getWorkspaceId()); - jsonTransformationDTO.setBaseArtifactId(branchedGitData.getDefaultArtifactId()); - jsonTransformationDTO.setRefName(branchedGitData.getRefName()); - jsonTransformationDTO.setRepoName(branchedGitData.getRepoName()); + jsonTransformationDTO.setRefName(branchName); - Mono recreatedArtifactFromLastCommit = gitRedisUtils - .acquireGitLock( - artifactType, - branchedGitData.getDefaultArtifactId(), - GitConstants.GitCommandConstants.DISCARD, - TRUE) - .then(gitHandlingService - .recreateArtifactJsonFromLastCommit(jsonTransformationDTO) - .onErrorResume(throwable -> { - log.error("Git recreate ArtifactJsonFailed : {}", throwable.getMessage()); - return gitRedisUtils - .releaseFileLock(artifactType, branchedGitData.getDefaultArtifactId(), TRUE) - .then( - Mono.error( - new AppsmithException( - AppsmithError.GIT_ACTION_FAILED, - "discard changes", - "Please create a new branch and resolve conflicts in the remote repository before proceeding."))); - })) - .flatMap(artifactExchangeJson -> importService.importArtifactInWorkspaceFromGit( - branchedArtifact.getWorkspaceId(), - branchedArtifact.getId(), - artifactExchangeJson, - branchedGitData.getRefName())) - // Update the last deployed status after the rebase - .flatMap(importedArtifact -> gitArtifactHelper.publishArtifact(importedArtifact, true)) - .flatMap(publishedArtifact -> { - return gitRedisUtils - .releaseFileLock( - artifactType, - publishedArtifact.getGitArtifactMetadata().getDefaultArtifactId(), - TRUE) - .then(gitAnalyticsUtils.addAnalyticsForGitOperation( - AnalyticsEvents.GIT_DISCARD_CHANGES, publishedArtifact, null)); - }) - .onErrorResume(error -> { - log.error( - "An error occurred while discarding branch with artifact id {}. error {}", - branchedGitData.getDefaultArtifactId(), - error.getMessage()); - return gitRedisUtils - .releaseFileLock(artifactType, branchedGitData.getDefaultArtifactId(), TRUE) - .then(Mono.error(new AppsmithException(AppsmithError.GIT_ACTION_FAILED, "checkout"))); - }) + Mono lockHandledRecreateArtifactFromLastCommit = Mono.usingWhen( + gitRedisUtils.acquireGitLock(artifactType, baseArtifactId, GitCommandConstants.DISCARD, TRUE), + ignoreLockAcquisition -> { + Mono artifactJsonFromLastCommitMono = gitHandlingService + .recreateArtifactJsonFromLastCommit(jsonTransformationDTO) + .onErrorResume(exception -> { + log.error("Git recreate Artifact Json Failed : {}", exception.getMessage()); + + return Mono.error( + new AppsmithException( + AppsmithError.GIT_ACTION_FAILED, + GitCommandConstants.DISCARD, + "Please create a new branch and resolve conflicts in the remote repository before proceeding.")); + }); + + return artifactJsonFromLastCommitMono + .flatMap(artifactExchangeJson -> importService.importArtifactInWorkspaceFromGit( + workspaceId, branchedArtifact.getId(), artifactExchangeJson, branchName)) + .flatMap(artifactFromLastCommit -> + gitArtifactHelper.publishArtifact(artifactFromLastCommit, true)) + .flatMap(publishedArtifact -> gitAnalyticsUtils.addAnalyticsForGitOperation( + AnalyticsEvents.GIT_DISCARD_CHANGES, publishedArtifact, null)) + .onErrorResume(exception -> { + log.error( + "An error occurred while discarding branched artifact id {}. error {}", + branchedArtifact.getId(), + exception.getMessage()); + + if (exception instanceof AppsmithException) { + return Mono.error(exception); + } + + return Mono.error(new AppsmithException( + AppsmithError.GIT_ACTION_FAILED, + GitCommandConstants.DISCARD, + exception.getMessage())); + }); + }, + ignoreLockAcquisition -> gitRedisUtils.releaseFileLock(artifactType, baseArtifactId, TRUE)) .name(GitSpan.OPS_DISCARD_CHANGES) .tap(Micrometer.observation(observationRegistry)); - return Mono.create(sink -> - recreatedArtifactFromLastCommit.subscribe(sink::success, sink::error, null, sink.currentContext())); + return Mono.create(sink -> lockHandledRecreateArtifactFromLastCommit.subscribe( + sink::success, sink::error, null, sink.currentContext())); } - public Mono> listBranchForArtifact( + public Mono> listBranchForArtifact( String branchedArtifactId, ArtifactType artifactType, Boolean pruneBranches, GitType gitType) { return getBranchList(branchedArtifactId, artifactType, pruneBranches, true, gitType); } - protected Mono> getBranchList( + protected Mono> getBranchList( String branchedArtifactId, ArtifactType artifactType, Boolean pruneBranches, @@ -2109,7 +2116,7 @@ protected Mono> getBranchList( }); } - protected Mono> getBranchList( + protected Mono> getBranchList( Artifact baseArtifact, Artifact branchedArtifact, Boolean pruneBranches, @@ -2128,15 +2135,6 @@ protected Mono> getBranchList( final String repoName = baseGitData.getRepoName(); final String currentBranch = branchedGitData.getRefName(); - ArtifactJsonTransformationDTO jsonTransformationDTO = new ArtifactJsonTransformationDTO(); - jsonTransformationDTO.setRepoName(repoName); - jsonTransformationDTO.setWorkspaceId(workspaceId); - jsonTransformationDTO.setBaseArtifactId(baseArtifactId); - jsonTransformationDTO.setRefName(currentBranch); - // not that it matters - jsonTransformationDTO.setRefType(branchedGitData.getRefType()); - jsonTransformationDTO.setArtifactType(baseArtifact.getArtifactType()); - if (!hasText(baseArtifactId) || !hasText(repoName) || !hasText(currentBranch)) { log.error( "Git config is not present for artifact {} of type {}", @@ -2145,6 +2143,12 @@ protected Mono> getBranchList( return Mono.error(new AppsmithException(AppsmithError.INVALID_GIT_CONFIGURATION, GIT_CONFIG_ERROR)); } + ArtifactJsonTransformationDTO jsonTransformationDTO = new ArtifactJsonTransformationDTO( + workspaceId, baseArtifactId, repoName, baseArtifact.getArtifactType()); + + jsonTransformationDTO.setRefName(currentBranch); + jsonTransformationDTO.setRefType(branchedGitData.getRefType()); + Mono baseBranchMono; if (TRUE.equals(pruneBranches) && syncDefaultBranchWithRemote) { baseBranchMono = syncDefaultBranchNameFromRemote(baseGitData, jsonTransformationDTO, gitType); @@ -2152,7 +2156,7 @@ protected Mono> getBranchList( baseBranchMono = Mono.just(GitUtils.getDefaultBranchName(baseGitData)); } - Mono> branchMono = baseBranchMono + Mono> branchMono = baseBranchMono .flatMap(baseBranchName -> { return getBranchListWithDefaultBranchName( baseArtifact, baseBranchName, currentBranch, pruneBranches, gitType); @@ -2258,7 +2262,7 @@ private Flux updateDefaultBranchName( }); } - private Mono> handleRepoNotFoundException( + private Mono> handleRepoNotFoundException( ArtifactJsonTransformationDTO jsonTransformationDTO, GitType gitType) { // clone artifact to the local git system again and update the defaultBranch for the artifact // list branch and compare with branch artifacts and checkout if not exists @@ -2283,13 +2287,14 @@ private Mono> handleRepoNotFoundException( .flatMap(defaultBranch -> gitHandlingService.listReferences(jsonTransformationDTO, true)) .flatMap(branches -> { List branchesToCheckout = new ArrayList<>(); - List gitBranchDTOList = new ArrayList<>(); + + List gitRefDTOs = new ArrayList<>(); for (String branch : branches) { GitBranchDTO gitBranchDTO = new GitBranchDTO(); gitBranchDTO.setBranchName(branch); if (branch.startsWith(ORIGIN)) { - // remove origin/ prefix from the remote branch name + // remove `origin/` prefix from the remote branch name String branchName = branch.replace(ORIGIN, REMOTE_NAME_REPLACEMENT); // The root defaultArtifact is always there, no need to check out it again if (!branchName.equals(gitArtifactMetadata.getBranchName())) { @@ -2319,90 +2324,102 @@ private Mono> handleRepoNotFoundException( // checkout the branch locally .flatMap(artifact -> { // Add the locally checked out branch to the branchList - GitBranchDTO gitBranchDTO = new GitBranchDTO(); - gitBranchDTO.setBranchName(branchName); + GitRefDTO gitRefDTO = new GitRefDTO(); + gitRefDTO.setRefName(branchName); + // set the default branch flag if there's a match. // This can happen when user has changed the default branch other - // than - // remote - gitBranchDTO.setDefault(gitArtifactMetadata + // than remote + gitRefDTO.setDefault(gitArtifactMetadata .getDefaultBranchName() .equals(branchName)); - gitBranchDTOList.add(gitBranchDTO); + gitRefDTOs.add(gitRefDTO); branchCheckoutDTO.setRefName(branchName); return gitHandlingService.checkoutRemoteReference(branchCheckoutDTO); }) // Return empty mono when the branched defaultArtifact is not in db .onErrorResume(throwable -> Mono.empty())) - .then(Mono.just(gitBranchDTOList)); + .then(Mono.just(gitRefDTOs)); }); }); } - private Mono> getBranchListWithDefaultBranchName( + private Mono> getBranchListWithDefaultBranchName( Artifact baseArtifact, String defaultBranchName, String currentBranch, boolean pruneBranches, GitType gitType) { - ArtifactType artifactType = baseArtifact.getArtifactType(); GitArtifactMetadata baseGitData = baseArtifact.getGitArtifactMetadata(); - GitHandlingService gitHandlingService = gitHandlingServiceResolver.getGitHandlingService(gitType); - ArtifactJsonTransformationDTO jsonTransformationDTO = new ArtifactJsonTransformationDTO(); - jsonTransformationDTO.setRepoName(baseGitData.getRepoName()); - jsonTransformationDTO.setWorkspaceId(baseArtifact.getWorkspaceId()); - jsonTransformationDTO.setBaseArtifactId(baseGitData.getDefaultArtifactId()); - jsonTransformationDTO.setRefName(currentBranch); - jsonTransformationDTO.setRefType(baseGitData.getRefType()); - jsonTransformationDTO.setArtifactType(baseArtifact.getArtifactType()); + String workspaceId = baseArtifact.getWorkspaceId(); + String baseArtifactId = baseGitData.getDefaultArtifactId(); + String repoName = baseGitData.getRepoName(); + RefType refType = RefType.branch; // baseGitData.getRefType(); + ArtifactType artifactType = baseArtifact.getArtifactType(); - return gitRedisUtils - .acquireGitLock( - artifactType, - baseGitData.getDefaultArtifactId(), - GitConstants.GitCommandConstants.LIST_BRANCH, - TRUE) - .flatMap(ignoredLock -> { - Mono> listBranchesMono = - Mono.defer(() -> gitHandlingService.listReferences(jsonTransformationDTO, true)); + return Mono.usingWhen( + gitRedisUtils.acquireGitLock( + artifactType, baseArtifactId, GitConstants.GitCommandConstants.LIST_BRANCH, TRUE), + ignoreLock -> { + GitHandlingService gitHandlingService = gitHandlingServiceResolver.getGitHandlingService(gitType); + ArtifactJsonTransformationDTO jsonTransformationDTO = + new ArtifactJsonTransformationDTO(workspaceId, baseArtifactId, repoName, artifactType); + jsonTransformationDTO.setRefName(currentBranch); + jsonTransformationDTO.setRefType(refType); + + Mono fetchRemoteMono = Mono.just(""); if (TRUE.equals(pruneBranches)) { - return gitHandlingService - .fetchRemoteReferences(jsonTransformationDTO, baseGitData.getGitAuth(), TRUE) - .then(listBranchesMono); + fetchRemoteMono = gitHandlingService.fetchRemoteReferences( + jsonTransformationDTO, baseGitData.getGitAuth(), TRUE); } - return listBranchesMono; - }) - .onErrorResume(error -> { - return gitRedisUtils - .releaseFileLock(artifactType, baseGitData.getDefaultArtifactId(), TRUE) - .then(Mono.error(error)); - }) - .flatMap(branches -> { - return gitRedisUtils - .releaseFileLock(artifactType, baseGitData.getDefaultArtifactId(), TRUE) - .thenReturn(branches.stream() - .map(branchName -> { - GitBranchDTO gitBranchDTO = new GitBranchDTO(); - gitBranchDTO.setBranchName(branchName); - if (branchName.equalsIgnoreCase(defaultBranchName)) { - gitBranchDTO.setDefault(true); - } - return gitBranchDTO; - }) - .toList()); - }) - .flatMap(gitBranchDTOList -> FALSE.equals(pruneBranches) - ? Mono.just(gitBranchDTOList) - : gitAnalyticsUtils - .addAnalyticsForGitOperation( - AnalyticsEvents.GIT_PRUNE, - baseArtifact, - baseArtifact.getGitArtifactMetadata().getIsRepoPrivate()) - .thenReturn(gitBranchDTOList)); + + Mono> listBranchesMono = + Mono.defer(() -> gitHandlingService.listReferences(jsonTransformationDTO, true)); + + return fetchRemoteMono + .then(listBranchesMono) + .onErrorResume(Mono::error) + .map(branches -> { + List gitRefDTOs = new ArrayList<>(); + List gitBranchDTOs = new ArrayList<>(); + + branches.forEach(branch -> { + GitBranchDTO gitBranchDTO = new GitBranchDTO(); + gitBranchDTO.setBranchName(branch); + gitBranchDTO.setDefault(branch.equalsIgnoreCase(defaultBranchName)); + gitBranchDTOs.add(gitBranchDTO); + }); + + branches.forEach(branch -> { + GitRefDTO gitRefDTO = new GitRefDTO(); + gitRefDTO.setRefName(branch); + gitRefDTO.setRefType(jsonTransformationDTO.getRefType()); + gitRefDTO.setDefault(branch.equalsIgnoreCase(defaultBranchName)); + gitRefDTOs.add(gitRefDTO); + }); + + return gitRefDTOs; + }) + .flatMap(gitRefDTOs -> { + if (!TRUE.equals(pruneBranches)) { + return Mono.just(gitRefDTOs); + } + + return gitAnalyticsUtils + .addAnalyticsForGitOperation( + AnalyticsEvents.GIT_PRUNE, + baseArtifact, + baseArtifact + .getGitArtifactMetadata() + .getIsRepoPrivate()) + .thenReturn(gitRefDTOs); + }); + }, + ignoreLock -> gitRedisUtils.releaseFileLock(artifactType, baseArtifactId, TRUE)); } @Override diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/git/central/GitHandlingServiceCE.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/git/central/GitHandlingServiceCE.java index 5c84bb374e4c..c52960207159 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/git/central/GitHandlingServiceCE.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/git/central/GitHandlingServiceCE.java @@ -65,7 +65,6 @@ Mono initialiseReadMe( Mono createFirstCommit(ArtifactJsonTransformationDTO jsonTransformationDTO, CommitDTO commitDTO); - // TODO: provide a proper name Mono prepareChangesToBeCommitted( ArtifactJsonTransformationDTO jsonTransformationDTO, ArtifactExchangeJson artifactExchangeJson); @@ -88,6 +87,7 @@ Mono recreateArtifactJsonFromLastCommit( Mono getStatus(ArtifactJsonTransformationDTO jsonTransformationDTO); Mono createGitReference( + ArtifactJsonTransformationDTO baseRefJsonTransformationDTO, ArtifactJsonTransformationDTO artifactJsonTransformationDTO, GitArtifactMetadata baseGitData, GitRefDTO gitRefDTO); diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/git/controllers/GitApplicationControllerCE.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/git/controllers/GitApplicationControllerCE.java index 9adf691c24d8..578ee90cb97a 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/git/controllers/GitApplicationControllerCE.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/git/controllers/GitApplicationControllerCE.java @@ -1,6 +1,5 @@ package com.appsmith.server.git.controllers; -import com.appsmith.external.dtos.GitBranchDTO; import com.appsmith.external.dtos.GitRefDTO; import com.appsmith.external.dtos.GitStatusDTO; import com.appsmith.external.dtos.MergeStatusDTO; @@ -181,10 +180,12 @@ public Mono> mergeStatus( @JsonView(Views.Public.class) @DeleteMapping("/{baseArtifactId}/ref") public Mono> deleteBranch( - @PathVariable String baseArtifactId, @RequestBody GitRefDTO gitRefDTO) { - log.info("Going to delete ref {} for baseApplicationId {}", gitRefDTO.getRefName(), baseArtifactId); + @PathVariable String baseArtifactId, + @RequestParam String refName, + @RequestParam(required = false, defaultValue = "branch") RefType refType) { + log.info("Going to delete ref {} for baseApplicationId {}", refName, baseArtifactId); return centralGitService - .deleteGitReference(baseArtifactId, ARTIFACT_TYPE, gitRefDTO, GIT_TYPE) + .deleteGitReference(baseArtifactId, ARTIFACT_TYPE, refName, refType, GIT_TYPE) .map(application -> new ResponseDTO<>(HttpStatus.OK.value(), application, null)); } @@ -198,7 +199,7 @@ public Mono> discardChanges(@PathVariable String } @JsonView(Views.Public.class) - @PostMapping("/{baseArtifactId}/branch/protected") + @PostMapping("/{baseArtifactId}/protected-branches") public Mono>> updateProtectedBranches( @PathVariable String baseArtifactId, @RequestBody @Valid BranchProtectionRequestDTO branchProtectionRequestDTO) { @@ -208,7 +209,7 @@ public Mono>> updateProtectedBranches( } @JsonView(Views.Public.class) - @GetMapping("/{baseArtifactId}/branch/protected") + @GetMapping("/{baseArtifactId}/protected-branches") public Mono>> getProtectedBranches(@PathVariable String baseArtifactId) { return centralGitService .getProtectedBranches(baseArtifactId, ARTIFACT_TYPE) @@ -242,9 +243,10 @@ public Mono> toggleAutoCommitEnabled(@PathVariable String b } @JsonView(Views.Public.class) - @GetMapping("/{branchedApplicationId}/branches") - public Mono>> branch( + @GetMapping("/{branchedApplicationId}/refs") + public Mono>> getReferences( @PathVariable String branchedApplicationId, + @RequestParam(required = false, defaultValue = "branch") RefType refType, @RequestParam(required = false, defaultValue = "false") Boolean pruneBranches) { log.debug("Going to get branch list for application {}", branchedApplicationId); return centralGitService diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/git/controllers/GitArtifactControllerCE.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/git/controllers/GitArtifactControllerCE.java index d2fd03b8ad04..2ea2a29d583c 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/git/controllers/GitArtifactControllerCE.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/git/controllers/GitArtifactControllerCE.java @@ -4,6 +4,7 @@ import com.appsmith.server.constants.ArtifactType; import com.appsmith.server.constants.Url; import com.appsmith.server.domains.GitAuth; +import com.appsmith.server.domains.GitProfile; import com.appsmith.server.dtos.ArtifactImportDTO; import com.appsmith.server.dtos.GitConnectDTO; import com.appsmith.server.dtos.GitDeployKeyDTO; @@ -18,13 +19,16 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import reactor.core.publisher.Mono; import java.util.List; +import java.util.Map; @Slf4j @RequestMapping(Url.GIT_ARTIFACT_URL) @@ -36,6 +40,47 @@ public class GitArtifactControllerCE { protected static final GitType GIT_TYPE = GitType.FILE_SYSTEM; + /** + * artifact id is the base artifact id + * For every git connected artifact, the master branch artifact id is used as base application Id + * This is stored in gitArtifactId + * Note : The master branch here refers to the artifact that was created even before connecting to git + */ + @JsonView(Views.Public.class) + @PostMapping("/profile/default") + public Mono>> saveGitProfile(@RequestBody GitProfile gitProfile) { + log.debug("Going to add default git profile for user"); + return gitProfileUtils + .updateOrCreateGitProfileForCurrentUser(gitProfile) + .map(response -> new ResponseDTO<>(HttpStatus.OK.value(), response, null)); + } + + @JsonView(Views.Public.class) + @GetMapping("/profile/default") + public Mono> getDefaultGitConfigForUser() { + return gitProfileUtils + .getDefaultGitProfileOrCreateIfEmpty() + .map(gitConfigResponse -> new ResponseDTO<>(HttpStatus.OK.value(), gitConfigResponse, null)); + } + + @JsonView(Views.Public.class) + @PutMapping("/{baseApplicationId}/profile") + public Mono>> saveGitProfile( + @PathVariable String baseApplicationId, @RequestBody GitProfile gitProfile) { + log.debug("Going to add repo specific git profile for application: {}", baseApplicationId); + return gitProfileUtils + .updateOrCreateGitProfileForCurrentUser(gitProfile, baseApplicationId) + .map(response -> new ResponseDTO<>(HttpStatus.ACCEPTED.value(), response, null)); + } + + @JsonView(Views.Public.class) + @GetMapping("/{baseArtifactId}/profile") + public Mono> getGitConfigForUser(@PathVariable String baseArtifactId) { + return gitProfileUtils + .getGitProfileForUser(baseArtifactId) + .map(gitConfigResponse -> new ResponseDTO<>(HttpStatus.OK.value(), gitConfigResponse, null)); + } + @JsonView(Views.Public.class) @PostMapping("/import") public Mono> importArtifactFromGit( diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/git/fs/GitFSServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/git/fs/GitFSServiceCEImpl.java index b30f1fb0dd8b..129a7b62cbaf 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/git/fs/GitFSServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/git/fs/GitFSServiceCEImpl.java @@ -6,6 +6,7 @@ import com.appsmith.external.dtos.GitStatusDTO; import com.appsmith.external.dtos.MergeStatusDTO; import com.appsmith.external.git.constants.GitConstants; +import com.appsmith.external.git.constants.GitConstants.GitCommandConstants; import com.appsmith.external.git.constants.GitSpan; import com.appsmith.external.git.constants.ce.RefType; import com.appsmith.external.git.dtos.FetchRemoteDTO; @@ -70,6 +71,7 @@ import static com.appsmith.external.git.constants.ce.GitConstantsCE.EMPTY_COMMIT_ERROR_MESSAGE; import static com.appsmith.external.git.constants.ce.GitConstantsCE.GIT_CONFIG_ERROR; +import static java.lang.Boolean.TRUE; @Slf4j @Service @@ -252,8 +254,8 @@ public Mono> listBranches( .listBranches(repoSuffix) .flatMapMany(Flux::fromIterable) .filter(gitBranchDTO -> { - boolean branchToBeListed = !gitBranchDTO.getBranchName().startsWith("origin") - || Boolean.TRUE.equals(listRemoteBranches); + boolean branchToBeListed = + !gitBranchDTO.getBranchName().startsWith("origin") || TRUE.equals(listRemoteBranches); return StringUtils.hasText(gitBranchDTO.getBranchName()) && branchToBeListed; }) @@ -326,7 +328,7 @@ public Mono initialiseReadMe( try { return gitArtifactHelper .intialiseReadMe(artifact, readmePath, originHeader) - .map(path -> Boolean.TRUE); + .map(path -> TRUE); } catch (IOException ioException) { log.error("Error while creating readme file in the repository, {}", ioException.getMessage()); return Mono.error(new AppsmithException(AppsmithError.GIT_FILE_SYSTEM_ERROR, ioException.getMessage())); @@ -368,7 +370,7 @@ public Mono prepareChangesToBeCommitted( return commonGitFileUtils .saveArtifactToLocalRepoNew(repoSuffix, artifactExchangeJson, branchName) - .map(ignore -> Boolean.TRUE) + .map(ignore -> TRUE) .onErrorResume(e -> { log.error("Error in commit flow: ", e); if (e instanceof RepositoryNotFoundException) { @@ -513,8 +515,8 @@ protected Mono pushArtifact(Artifact branchedArtifact, boolean isFileLoc .flatMap(tuple2 -> { String pushStatus = tuple2.getT1(); Artifact artifact = tuple2.getT2(); - Mono fileLockReleasedMono = Mono.just(Boolean.TRUE).flatMap(flag -> { - if (!Boolean.TRUE.equals(isFileLock)) { + Mono fileLockReleasedMono = Mono.just(TRUE).flatMap(flag -> { + if (!TRUE.equals(isFileLock)) { return Mono.just(flag); } return Mono.defer(() -> gitRedisUtils.releaseFileLock( @@ -618,7 +620,8 @@ public Mono fetchRemoteReferences( String publicKey = gitAuth.getPublicKey(); String privateKey = gitAuth.getPrivateKey(); - if (CollectionUtils.isNullOrEmpty(fetchRemoteDTO.getRefNames())) { + if (CollectionUtils.isNullOrEmpty(fetchRemoteDTO.getRefNames()) + && !TRUE.equals(fetchRemoteDTO.getIsFetchAll())) { return Mono.error(new AppsmithException(AppsmithError.INVALID_GIT_CONFIGURATION)); } @@ -690,10 +693,15 @@ public Mono getStatus(ArtifactJsonTransformationDTO jsonTransforma @Override public Mono createGitReference( - ArtifactJsonTransformationDTO jsonTransformationDTO, GitArtifactMetadata baseGitData, GitRefDTO gitRefDTO) { + ArtifactJsonTransformationDTO baseRefJsonTransformationDTO, + ArtifactJsonTransformationDTO jsonTransformationDTO, + GitArtifactMetadata baseGitData, + GitRefDTO gitRefDTO) { GitArtifactHelper gitArtifactHelper = gitArtifactHelperResolver.getArtifactHelper(jsonTransformationDTO.getArtifactType()); + String baseRefName = baseRefJsonTransformationDTO.getRefName(); + String remoteUrl = baseGitData.getRemoteUrl(); String publicKey = baseGitData.getGitAuth().getPublicKey(); String privateKey = baseGitData.getGitAuth().getPrivateKey(); @@ -704,10 +712,10 @@ public Mono createGitReference( jsonTransformationDTO.getRepoName()); // TODO: add the checkout to the current branch as well. - return fsGitHandler + return fsGitHandler.checkoutToBranch(repoSuffix, baseRefName).flatMap(isCheckedOut -> fsGitHandler .createAndCheckoutReference(repoSuffix, gitRefDTO) - .then(fsGitHandler.pushApplication( - repoSuffix, remoteUrl, publicKey, privateKey, gitRefDTO.getRefName())); + .flatMap(newRef -> fsGitHandler.pushApplication( + repoSuffix, remoteUrl, publicKey, privateKey, gitRefDTO.getRefName()))); } @Override @@ -739,7 +747,7 @@ public Mono deleteGitReference(ArtifactJsonTransformationDTO jsonTransf log.error("Delete branch failed {}", throwable.getMessage()); Mono releaseLockMono = gitRedisUtils.releaseFileLock( - artifactType, jsonTransformationDTO.getBaseArtifactId(), Boolean.TRUE); + artifactType, jsonTransformationDTO.getBaseArtifactId(), TRUE); if (throwable instanceof CannotDeleteCurrentBranchException) { return releaseLockMono.then(Mono.error(new AppsmithException( @@ -780,16 +788,15 @@ public Mono pullArtifact( String branchName = jsonTransformationDTO.getRefName(); - // git checkout and pull origin branchName + // pull remote branchName try { return fsGitHandler - .checkoutToBranch(repoSuffix, jsonTransformationDTO.getRefName()) - .then(fsGitHandler.pullApplication( + .pullArtifactWithoutCheckout( repoSuffix, baseMetadata.getRemoteUrl(), branchName, baseMetadata.getGitAuth().getPrivateKey(), - baseMetadata.getGitAuth().getPublicKey())) + baseMetadata.getGitAuth().getPublicKey()) .onErrorResume(error -> { if (error.getMessage().contains("conflict")) { return Mono.error( @@ -800,8 +807,9 @@ public Mono pullArtifact( mergeStatus.setMergeAble(true); return Mono.just(mergeStatus); } - return Mono.error( - new AppsmithException(AppsmithError.GIT_ACTION_FAILED, "pull", error.getMessage())); + + return Mono.error(new AppsmithException( + AppsmithError.GIT_ACTION_FAILED, GitCommandConstants.PULL, error.getMessage())); }); } catch (IOException e) { return Mono.error(new AppsmithException(AppsmithError.GIT_FILE_SYSTEM_ERROR, e.getMessage())); diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/FeatureFlagServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/FeatureFlagServiceCEImpl.java index fda8d2da3764..d24c5186892d 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/FeatureFlagServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/FeatureFlagServiceCEImpl.java @@ -70,6 +70,8 @@ public Mono> getAllFeatureFlagsForUser() { .map(remoteAndTenantFlags -> { Map combinedFlags = new HashMap<>(); combinedFlags.putAll(remoteAndTenantFlags.getT1()); + combinedFlags.put("release_query_module_enabled", true); + combinedFlags.put("release_anvil_enabled", false); // Always add the tenant level flags after the user flags to make sure tenant flags gets the // precedence combinedFlags.putAll(remoteAndTenantFlags.getT2()); diff --git a/app/server/appsmith-server/src/test/it/com/appsmith/server/git/GitBranchesITWithCentralService.java b/app/server/appsmith-server/src/test/it/com/appsmith/server/git/GitBranchesITWithCentralService.java index c6ba7e8ae458..613aea6c0969 100644 --- a/app/server/appsmith-server/src/test/it/com/appsmith/server/git/GitBranchesITWithCentralService.java +++ b/app/server/appsmith-server/src/test/it/com/appsmith/server/git/GitBranchesITWithCentralService.java @@ -1,6 +1,5 @@ package com.appsmith.server.git; -import com.appsmith.external.dtos.GitBranchDTO; import com.appsmith.external.dtos.GitRefDTO; import com.appsmith.external.dtos.GitStatusDTO; import com.appsmith.external.dtos.MergeStatusDTO; @@ -437,7 +436,7 @@ void test(GitContext gitContext, ExtensionContext extensionContext) throws IOExc // Delete foo locally and re-populate from remote List branchList = centralGitService.listBranchForArtifact(artifactId, artifactType, false, GitType.FILE_SYSTEM) .flatMapMany(Flux::fromIterable) - .map(GitBranchDTO::getBranchName) + .map(GitRefDTO::getRefName) .collectList() .block(); assertThat(branchList).containsExactlyInAnyOrder( @@ -448,7 +447,7 @@ void test(GitContext gitContext, ExtensionContext extensionContext) throws IOExc barMetadata.getRefName(), "origin/" + barMetadata.getRefName()); - Mono deleteBranchAttemptMono = centralGitService.deleteGitReference(artifactId, artifactType, gitRefDTO, GitType.FILE_SYSTEM); + Mono deleteBranchAttemptMono = centralGitService.deleteGitReference(artifactId, artifactType, gitRefDTO.getRefName(), gitRefDTO.getRefType(), GitType.FILE_SYSTEM); StepVerifier .create(deleteBranchAttemptMono) .expectErrorSatisfies(e -> assertThat(e.getMessage()).contains("Cannot delete current checked out branch")) @@ -461,14 +460,11 @@ void test(GitContext gitContext, ExtensionContext extensionContext) throws IOExc git.checkout().setName("bar").call(); } - GitRefDTO deleteFooDTO = new GitRefDTO(); - deleteFooDTO.setRefType(RefType.branch); - deleteFooDTO.setRefName("foo"); - centralGitService.deleteGitReference(artifactId, artifactType, deleteFooDTO, GitType.FILE_SYSTEM).block(); + centralGitService.deleteGitReference(artifactId, artifactType, "foo", RefType.branch, GitType.FILE_SYSTEM).block(); List branchList2 = centralGitService.listBranchForArtifact(artifactId, artifactType, false, GitType.FILE_SYSTEM) .flatMapMany(Flux::fromIterable) - .map(GitBranchDTO::getBranchName) + .map(GitRefDTO::getRefName) .collectList() .block(); assertThat(branchList2).containsExactlyInAnyOrder( @@ -486,7 +482,7 @@ void test(GitContext gitContext, ExtensionContext extensionContext) throws IOExc assertThat(checkedOutFooArtifact).isNotNull(); List branchList3 = centralGitService.listBranchForArtifact(artifactId, artifactType, false, GitType.FILE_SYSTEM) .flatMapMany(Flux::fromIterable) - .map(GitBranchDTO::getBranchName) + .map(GitRefDTO::getRefName) .collectList() .block(); assertThat(branchList3).containsExactlyInAnyOrder( From 8833a05e2f02a8904311a5f01b3f7691f7c43c70 Mon Sep 17 00:00:00 2001 From: sondermanish Date: Mon, 3 Feb 2025 13:30:06 +0530 Subject: [PATCH 2/5] added removed feature flag extras --- .../appsmith/server/services/ce/FeatureFlagServiceCEImpl.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/FeatureFlagServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/FeatureFlagServiceCEImpl.java index d24c5186892d..fda8d2da3764 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/FeatureFlagServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/FeatureFlagServiceCEImpl.java @@ -70,8 +70,6 @@ public Mono> getAllFeatureFlagsForUser() { .map(remoteAndTenantFlags -> { Map combinedFlags = new HashMap<>(); combinedFlags.putAll(remoteAndTenantFlags.getT1()); - combinedFlags.put("release_query_module_enabled", true); - combinedFlags.put("release_anvil_enabled", false); // Always add the tenant level flags after the user flags to make sure tenant flags gets the // precedence combinedFlags.putAll(remoteAndTenantFlags.getT2()); From f85c2bbc5ffa6604c6e69a7b3e476538f6a61e14 Mon Sep 17 00:00:00 2001 From: sondermanish Date: Mon, 3 Feb 2025 17:07:46 +0530 Subject: [PATCH 3/5] added review changes --- .../git/constants/ce/GitConstantsCE.java | 2 ++ .../git/central/CentralGitServiceCEImpl.java | 20 +++++++------------ 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/ce/GitConstantsCE.java b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/ce/GitConstantsCE.java index 7ca6ac4127bc..9aa0c308b8f4 100644 --- a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/ce/GitConstantsCE.java +++ b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/ce/GitConstantsCE.java @@ -46,7 +46,9 @@ public class GitCommandConstantsCE { public static final String FETCH_REMOTE = "fetchRemote"; public static final String COMMIT = "commit"; public static final String CREATE_BRANCH = "createBranch"; + public static final String CREATE_REF = "createRef"; public static final String CHECKOUT_BRANCH = "checkoutBranch"; + public static final String CHECKOUT_REF = "checkoutRef"; public static final String SYNC_BRANCH = "syncBranch"; public static final String LIST_BRANCH = "listBranch"; public static final String MERGE_BRANCH = "mergeBranch"; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/git/central/CentralGitServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/git/central/CentralGitServiceCEImpl.java index 87617432cd8f..58059e906d57 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/git/central/CentralGitServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/git/central/CentralGitServiceCEImpl.java @@ -415,10 +415,7 @@ protected Mono checkoutReference( GitHandlingService gitHandlingService = gitHandlingServiceResolver.getGitHandlingService(gitType); Mono acquireFileLock = gitRedisUtils.acquireGitLock( - baseArtifact.getArtifactType(), - baseArtifactId, - GitConstants.GitCommandConstants.CHECKOUT_BRANCH, - addFileLock); + baseArtifact.getArtifactType(), baseArtifactId, GitCommandConstants.CHECKOUT_REF, addFileLock); Mono checkedOutArtifactMono; // If the user is trying to check out remote reference, create a new reference if it does not exist already @@ -446,7 +443,7 @@ protected Mono checkoutReference( return Mono.error(new AppsmithException( AppsmithError.GIT_ACTION_FAILED, - GitCommandConstants.CHECKOUT_BRANCH, + GitCommandConstants.CHECKOUT_REF, gitRefDTO.getRefName() + " already exists in local - " + finalRefName)); }); } else { @@ -632,10 +629,7 @@ protected Mono createReference( createRefTransformationDTO.setRefName(refDTO.getRefName()); Mono acquireGitLockMono = gitRedisUtils.acquireGitLock( - artifactType, - baseGitMetadata.getDefaultArtifactId(), - GitConstants.GitCommandConstants.CREATE_BRANCH, - FALSE); + artifactType, baseGitMetadata.getDefaultArtifactId(), GitCommandConstants.CREATE_REF, FALSE); FetchRemoteDTO fetchRemoteDTO = new FetchRemoteDTO(); fetchRemoteDTO.setRefType(refType); @@ -724,7 +718,7 @@ protected Mono createReference( .releaseFileLock(artifactType, baseArtifactId, TRUE) .then(Mono.error(new AppsmithException( AppsmithError.GIT_ACTION_FAILED, - GitCommandConstants.CREATE_BRANCH, + GitCommandConstants.CREATE_REF, error.getMessage()))); }) .name(GitSpan.OPS_CREATE_BRANCH) @@ -2042,7 +2036,7 @@ protected Mono discardChanges(Artifact branchedArtifact, Git jsonTransformationDTO.setRefType(RefType.branch); jsonTransformationDTO.setRefName(branchName); - Mono lockHandledRecreateArtifactFromLastCommit = Mono.usingWhen( + Mono artifactFromLastCommitMono = Mono.usingWhen( gitRedisUtils.acquireGitLock(artifactType, baseArtifactId, GitCommandConstants.DISCARD, TRUE), ignoreLockAcquisition -> { Mono artifactJsonFromLastCommitMono = gitHandlingService @@ -2084,8 +2078,8 @@ protected Mono discardChanges(Artifact branchedArtifact, Git .name(GitSpan.OPS_DISCARD_CHANGES) .tap(Micrometer.observation(observationRegistry)); - return Mono.create(sink -> lockHandledRecreateArtifactFromLastCommit.subscribe( - sink::success, sink::error, null, sink.currentContext())); + return Mono.create( + sink -> artifactFromLastCommitMono.subscribe(sink::success, sink::error, null, sink.currentContext())); } public Mono> listBranchForArtifact( From 3cf61556c05d8d4c4328ea715981e42a0c6221d0 Mon Sep 17 00:00:00 2001 From: sondermanish Date: Mon, 3 Feb 2025 20:52:16 +0530 Subject: [PATCH 4/5] added client side changes --- app/client/src/git/hooks/useCommit.ts | 4 ++-- app/client/src/git/requests/commitRequest.types.ts | 2 +- app/client/src/git/requests/fetchProtectedBranchesRequest.ts | 2 +- app/client/src/git/requests/gitImportRequest.ts | 3 +-- app/client/src/git/requests/updateProtectedBranchesRequest.ts | 2 +- app/client/src/git/sagas/commitSaga.ts | 2 +- 6 files changed, 7 insertions(+), 8 deletions(-) diff --git a/app/client/src/git/hooks/useCommit.ts b/app/client/src/git/hooks/useCommit.ts index 6a468046a84b..3c20372f6121 100644 --- a/app/client/src/git/hooks/useCommit.ts +++ b/app/client/src/git/hooks/useCommit.ts @@ -14,13 +14,13 @@ export default function useCommit() { const commitState = useArtifactSelector(selectCommitState); const commit = useCallback( - (commitMessage: string) => { + (message: string) => { if (artifactDef && artifactId) { dispatch( gitArtifactActions.commitInit({ artifactId, artifactDef, - commitMessage, + message, doPush: true, }), ); diff --git a/app/client/src/git/requests/commitRequest.types.ts b/app/client/src/git/requests/commitRequest.types.ts index 68f8aeb2cedc..7485a66893b7 100644 --- a/app/client/src/git/requests/commitRequest.types.ts +++ b/app/client/src/git/requests/commitRequest.types.ts @@ -1,7 +1,7 @@ import type { ApiResponse } from "api/types"; export interface CommitRequestParams { - commitMessage: string; + message: string; doPush: boolean; } diff --git a/app/client/src/git/requests/fetchProtectedBranchesRequest.ts b/app/client/src/git/requests/fetchProtectedBranchesRequest.ts index 762f88038e71..b79c9927dfc1 100644 --- a/app/client/src/git/requests/fetchProtectedBranchesRequest.ts +++ b/app/client/src/git/requests/fetchProtectedBranchesRequest.ts @@ -14,7 +14,7 @@ async function fetchProtectedBranchesRequestNew( artifactType: GitArtifactType, baseArtifactId: string, ): AxiosPromise { - return Api.get(`${GIT_BASE_URL}/${artifactType}/${baseArtifactId}/protected`); + return Api.get(`${GIT_BASE_URL}/${artifactType}/${baseArtifactId}/protected-branches`); } export default async function fetchProtectedBranchesRequest( diff --git a/app/client/src/git/requests/gitImportRequest.ts b/app/client/src/git/requests/gitImportRequest.ts index 6d05dd543212..f07bd197e893 100644 --- a/app/client/src/git/requests/gitImportRequest.ts +++ b/app/client/src/git/requests/gitImportRequest.ts @@ -17,8 +17,7 @@ async function gitImportRequestNew( workspaceId: string, params: GitImportRequestParams, ): AxiosPromise { - return Api.post(`${GIT_BASE_URL}/artifacts/import`, params, { - params: { workspaceId }, + return Api.post(`${GIT_BASE_URL}/artifacts/import`, params, {workspaceId, }); } diff --git a/app/client/src/git/requests/updateProtectedBranchesRequest.ts b/app/client/src/git/requests/updateProtectedBranchesRequest.ts index 034126986789..c7135e2630ed 100644 --- a/app/client/src/git/requests/updateProtectedBranchesRequest.ts +++ b/app/client/src/git/requests/updateProtectedBranchesRequest.ts @@ -23,7 +23,7 @@ async function updateProtectedBranchesRequestNew( params: UpdateProtectedBranchesRequestParams, ): AxiosPromise { return Api.post( - `${GIT_BASE_URL}/${artifactType}/${baseArtifactId}/protected`, + `${GIT_BASE_URL}/${artifactType}/${baseArtifactId}/protected-branches`, params, ); } diff --git a/app/client/src/git/sagas/commitSaga.ts b/app/client/src/git/sagas/commitSaga.ts index 203baf485d36..9a0f058380d9 100644 --- a/app/client/src/git/sagas/commitSaga.ts +++ b/app/client/src/git/sagas/commitSaga.ts @@ -28,7 +28,7 @@ export default function* commitSaga( try { const params: CommitRequestParams = { - commitMessage: action.payload.commitMessage, + message: action.payload.message, doPush: action.payload.doPush, }; const isGitApiContractsEnabled: boolean = yield select( From 6d936712cc73629489b042623d181328e6be2d01 Mon Sep 17 00:00:00 2001 From: sondermanish Date: Tue, 4 Feb 2025 11:43:18 +0530 Subject: [PATCH 5/5] linting changes --- app/client/src/git/requests/fetchProtectedBranchesRequest.ts | 4 +++- app/client/src/git/requests/gitImportRequest.ts | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/client/src/git/requests/fetchProtectedBranchesRequest.ts b/app/client/src/git/requests/fetchProtectedBranchesRequest.ts index b79c9927dfc1..2d959a8132af 100644 --- a/app/client/src/git/requests/fetchProtectedBranchesRequest.ts +++ b/app/client/src/git/requests/fetchProtectedBranchesRequest.ts @@ -14,7 +14,9 @@ async function fetchProtectedBranchesRequestNew( artifactType: GitArtifactType, baseArtifactId: string, ): AxiosPromise { - return Api.get(`${GIT_BASE_URL}/${artifactType}/${baseArtifactId}/protected-branches`); + return Api.get( + `${GIT_BASE_URL}/${artifactType}/${baseArtifactId}/protected-branches`, + ); } export default async function fetchProtectedBranchesRequest( diff --git a/app/client/src/git/requests/gitImportRequest.ts b/app/client/src/git/requests/gitImportRequest.ts index f07bd197e893..3ee6dcdfcba7 100644 --- a/app/client/src/git/requests/gitImportRequest.ts +++ b/app/client/src/git/requests/gitImportRequest.ts @@ -17,8 +17,7 @@ async function gitImportRequestNew( workspaceId: string, params: GitImportRequestParams, ): AxiosPromise { - return Api.post(`${GIT_BASE_URL}/artifacts/import`, params, {workspaceId, - }); + return Api.post(`${GIT_BASE_URL}/artifacts/import`, params, { workspaceId }); } export default async function gitImportRequest(