chore: package refactors and left over changes for git autocommit pr (#33768)

## Description
- Adding refactors

## Automation

/ok-to-test tags="@tag.Git"

### 🔍 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/9284429088>
> Commit: 51302159c5aad387ae03515bfbb65916f8bd505d
> Cypress dashboard url: <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9284429088&attempt=4"
target="_blank">Click here!</a>

<!-- end of auto-generated comment: Cypress test results  -->









## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No
This commit is contained in:
Manish Kumar 2024-05-29 17:42:23 +05:30 committed by GitHub
parent 2b8f49930f
commit e03b1ed042
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
25 changed files with 47 additions and 41 deletions

View File

@ -1,4 +1,4 @@
package com.appsmith.server.helpers.ce.autocommit;
package com.appsmith.server.dtos;
import lombok.AllArgsConstructor;
import lombok.Data;

View File

@ -0,0 +1,3 @@
package com.appsmith.server.git;
public interface AutoCommitEventHandler extends AutoCommitEventHandlerCE {}

View File

@ -1,4 +1,4 @@
package com.appsmith.server.solutions.ce;
package com.appsmith.server.git;
import com.appsmith.server.events.AutoCommitEvent;
import reactor.core.publisher.Mono;

View File

@ -1,4 +1,4 @@
package com.appsmith.server.solutions.ce;
package com.appsmith.server.git;
import com.appsmith.external.constants.AnalyticsEvents;
import com.appsmith.external.dtos.ModifiedResources;

View File

@ -1,4 +1,4 @@
package com.appsmith.server.solutions;
package com.appsmith.server.git;
import com.appsmith.external.git.GitExecutor;
import com.appsmith.server.configurations.ProjectProperties;
@ -7,7 +7,6 @@ import com.appsmith.server.helpers.DSLMigrationUtils;
import com.appsmith.server.helpers.GitFileUtils;
import com.appsmith.server.helpers.RedisUtils;
import com.appsmith.server.services.AnalyticsService;
import com.appsmith.server.solutions.ce.AutoCommitEventHandlerCEImpl;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Component;

View File

@ -17,17 +17,19 @@ public class GitRedisUtils {
private final RedisUtils redisUtils;
public Mono<Boolean> addFileLock(String defaultApplicationId) {
public Mono<Boolean> addFileLock(String defaultApplicationId, Boolean isRetryAllowed) {
long numberOfRetries = Boolean.TRUE.equals(isRetryAllowed) ? MAX_RETRIES : 0L;
return redisUtils
.addFileLock(defaultApplicationId)
.retryWhen(Retry.fixedDelay(MAX_RETRIES, RETRY_DELAY)
.retryWhen(Retry.fixedDelay(numberOfRetries, RETRY_DELAY)
.onRetryExhaustedThrow((retryBackoffSpec, retrySignal) -> {
throw new AppsmithException(AppsmithError.GIT_FILE_IN_USE);
}));
}
public Mono<Boolean> addFileLockWithoutRetry(String defaultApplicationId) {
return redisUtils.addFileLock(defaultApplicationId);
public Mono<Boolean> addFileLock(String defaultApplicationId) {
return addFileLock(defaultApplicationId, Boolean.TRUE);
}
public Mono<Boolean> releaseFileLock(String defaultApplicationId) {

View File

@ -1,6 +1,7 @@
package com.appsmith.server.helpers.ce.autocommit;
package com.appsmith.server.git.autocommit.helpers;
import com.appsmith.server.domains.GitArtifactMetadata;
import com.appsmith.server.dtos.AutoCommitTriggerDTO;
import com.appsmith.server.dtos.PageDTO;
import reactor.core.publisher.Mono;

View File

@ -1,6 +1,7 @@
package com.appsmith.server.helpers.ce.autocommit;
package com.appsmith.server.git.autocommit.helpers;
import com.appsmith.server.domains.GitArtifactMetadata;
import com.appsmith.server.dtos.AutoCommitTriggerDTO;
import com.appsmith.server.dtos.PageDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

View File

@ -1,10 +1,11 @@
package com.appsmith.server.helpers.ce.autocommit;
package com.appsmith.server.git.autocommit.helpers;
import com.appsmith.external.annotations.FeatureFlagged;
import com.appsmith.external.enums.FeatureFlagEnum;
import com.appsmith.server.constants.ArtifactType;
import com.appsmith.server.domains.GitArtifactMetadata;
import com.appsmith.server.domains.Layout;
import com.appsmith.server.dtos.AutoCommitTriggerDTO;
import com.appsmith.server.dtos.PageDTO;
import com.appsmith.server.git.GitRedisUtils;
import com.appsmith.server.helpers.CommonGitFileUtils;
@ -54,7 +55,7 @@ public class AutoCommitEligibilityHelperImpl extends AutoCommitEligibilityHelper
.defaultIfEmpty(FALSE)
.cache();
return Mono.defer(() -> gitRedisUtils.addFileLockWithoutRetry(defaultApplicationId))
return Mono.defer(() -> gitRedisUtils.addFileLock(defaultApplicationId, FALSE))
.then(Mono.defer(() -> isServerMigrationRequiredMonoCached))
.then(Mono.defer(() -> gitRedisUtils.releaseFileLock(defaultApplicationId)))
.then(Mono.defer(() -> isServerMigrationRequiredMonoCached))

View File

@ -1,6 +1,7 @@
package com.appsmith.server.helpers.ce.autocommit;
package com.appsmith.server.git.autocommit.helpers;
import com.appsmith.server.dtos.AutoCommitProgressDTO;
import com.appsmith.server.dtos.AutoCommitTriggerDTO;
import reactor.core.publisher.Mono;
public interface GitAutoCommitHelper {

View File

@ -1,6 +1,7 @@
package com.appsmith.server.helpers.ce.autocommit;
package com.appsmith.server.git.autocommit.helpers;
import com.appsmith.server.dtos.AutoCommitProgressDTO;
import com.appsmith.server.dtos.AutoCommitTriggerDTO;
import org.springframework.stereotype.Component;
import reactor.core.publisher.Mono;

View File

@ -1,4 +1,4 @@
package com.appsmith.server.helpers.ce.autocommit;
package com.appsmith.server.git.autocommit.helpers;
import com.appsmith.external.annotations.FeatureFlagged;
import com.appsmith.external.enums.FeatureFlagEnum;
@ -7,14 +7,15 @@ import com.appsmith.server.domains.Application;
import com.appsmith.server.domains.GitArtifactMetadata;
import com.appsmith.server.domains.GitProfile;
import com.appsmith.server.dtos.AutoCommitProgressDTO;
import com.appsmith.server.dtos.AutoCommitTriggerDTO;
import com.appsmith.server.events.AutoCommitEvent;
import com.appsmith.server.git.AutoCommitEventHandler;
import com.appsmith.server.helpers.GitPrivateRepoHelper;
import com.appsmith.server.helpers.GitUtils;
import com.appsmith.server.helpers.RedisUtils;
import com.appsmith.server.services.CommonGitService;
import com.appsmith.server.services.UserDataService;
import com.appsmith.server.solutions.ApplicationPermission;
import com.appsmith.server.solutions.AutoCommitEventHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Primary;

View File

@ -6,11 +6,11 @@ import com.appsmith.server.applications.base.ApplicationService;
import com.appsmith.server.clonepage.ClonePageService;
import com.appsmith.server.domains.ActionCollection;
import com.appsmith.server.domains.NewAction;
import com.appsmith.server.git.autocommit.helpers.AutoCommitEligibilityHelper;
import com.appsmith.server.git.autocommit.helpers.GitAutoCommitHelper;
import com.appsmith.server.helpers.DSLMigrationUtils;
import com.appsmith.server.helpers.GitFileUtils;
import com.appsmith.server.helpers.ResponseUtils;
import com.appsmith.server.helpers.ce.autocommit.AutoCommitEligibilityHelper;
import com.appsmith.server.helpers.ce.autocommit.GitAutoCommitHelper;
import com.appsmith.server.layouts.UpdateLayoutService;
import com.appsmith.server.newactions.base.NewActionService;
import com.appsmith.server.newpages.base.NewPageService;

View File

@ -5,10 +5,10 @@ import com.appsmith.git.service.GitExecutorImpl;
import com.appsmith.server.configurations.EmailConfig;
import com.appsmith.server.domains.Application;
import com.appsmith.server.exports.internal.ExportService;
import com.appsmith.server.git.autocommit.helpers.GitAutoCommitHelper;
import com.appsmith.server.helpers.CommonGitFileUtils;
import com.appsmith.server.helpers.GitPrivateRepoHelper;
import com.appsmith.server.helpers.RedisUtils;
import com.appsmith.server.helpers.ce.autocommit.GitAutoCommitHelper;
import com.appsmith.server.imports.internal.ImportService;
import com.appsmith.server.repositories.GitDeployKeysRepository;
import com.appsmith.server.services.ce_compatible.CommonGitServiceCECompatibleImpl;

View File

@ -7,11 +7,11 @@ import com.appsmith.server.applications.base.ApplicationService;
import com.appsmith.server.configurations.EmailConfig;
import com.appsmith.server.datasources.base.DatasourceService;
import com.appsmith.server.exports.internal.ExportService;
import com.appsmith.server.git.autocommit.helpers.GitAutoCommitHelper;
import com.appsmith.server.helpers.GitFileUtils;
import com.appsmith.server.helpers.GitPrivateRepoHelper;
import com.appsmith.server.helpers.RedisUtils;
import com.appsmith.server.helpers.ResponseUtils;
import com.appsmith.server.helpers.ce.autocommit.GitAutoCommitHelper;
import com.appsmith.server.imports.internal.ImportService;
import com.appsmith.server.newactions.base.NewActionService;
import com.appsmith.server.newpages.base.NewPageService;

View File

@ -34,14 +34,14 @@ import com.appsmith.server.dtos.PageNameIdDTO;
import com.appsmith.server.dtos.PluginTypeAndCountDTO;
import com.appsmith.server.exceptions.AppsmithError;
import com.appsmith.server.exceptions.AppsmithException;
import com.appsmith.server.git.autocommit.helpers.AutoCommitEligibilityHelper;
import com.appsmith.server.git.autocommit.helpers.GitAutoCommitHelper;
import com.appsmith.server.helpers.CollectionUtils;
import com.appsmith.server.helpers.DSLMigrationUtils;
import com.appsmith.server.helpers.GitFileUtils;
import com.appsmith.server.helpers.GitUtils;
import com.appsmith.server.helpers.ResponseUtils;
import com.appsmith.server.helpers.UserPermissionUtils;
import com.appsmith.server.helpers.ce.autocommit.AutoCommitEligibilityHelper;
import com.appsmith.server.helpers.ce.autocommit.GitAutoCommitHelper;
import com.appsmith.server.layouts.UpdateLayoutService;
import com.appsmith.server.migrations.ApplicationVersion;
import com.appsmith.server.newactions.base.NewActionService;

View File

@ -35,13 +35,13 @@ import com.appsmith.server.dtos.GitPullDTO;
import com.appsmith.server.exceptions.AppsmithError;
import com.appsmith.server.exceptions.AppsmithException;
import com.appsmith.server.exports.internal.ExportService;
import com.appsmith.server.git.autocommit.helpers.GitAutoCommitHelper;
import com.appsmith.server.helpers.CollectionUtils;
import com.appsmith.server.helpers.CommonGitFileUtils;
import com.appsmith.server.helpers.GitDeployKeyGenerator;
import com.appsmith.server.helpers.GitPrivateRepoHelper;
import com.appsmith.server.helpers.GitUtils;
import com.appsmith.server.helpers.RedisUtils;
import com.appsmith.server.helpers.ce.autocommit.GitAutoCommitHelper;
import com.appsmith.server.imports.internal.ImportService;
import com.appsmith.server.repositories.GitDeployKeysRepository;
import com.appsmith.server.services.AnalyticsService;

View File

@ -43,6 +43,7 @@ import com.appsmith.server.dtos.GitPullDTO;
import com.appsmith.server.exceptions.AppsmithError;
import com.appsmith.server.exceptions.AppsmithException;
import com.appsmith.server.exports.internal.ExportService;
import com.appsmith.server.git.autocommit.helpers.GitAutoCommitHelper;
import com.appsmith.server.helpers.CollectionUtils;
import com.appsmith.server.helpers.GitDeployKeyGenerator;
import com.appsmith.server.helpers.GitFileUtils;
@ -50,7 +51,6 @@ import com.appsmith.server.helpers.GitPrivateRepoHelper;
import com.appsmith.server.helpers.GitUtils;
import com.appsmith.server.helpers.RedisUtils;
import com.appsmith.server.helpers.ResponseUtils;
import com.appsmith.server.helpers.ce.autocommit.GitAutoCommitHelper;
import com.appsmith.server.imports.internal.ImportService;
import com.appsmith.server.migrations.JsonSchemaVersions;
import com.appsmith.server.newactions.base.NewActionService;

View File

@ -4,10 +4,10 @@ import com.appsmith.external.git.GitExecutor;
import com.appsmith.server.configurations.EmailConfig;
import com.appsmith.server.domains.Application;
import com.appsmith.server.exports.internal.ExportService;
import com.appsmith.server.git.autocommit.helpers.GitAutoCommitHelper;
import com.appsmith.server.helpers.CommonGitFileUtils;
import com.appsmith.server.helpers.GitPrivateRepoHelper;
import com.appsmith.server.helpers.RedisUtils;
import com.appsmith.server.helpers.ce.autocommit.GitAutoCommitHelper;
import com.appsmith.server.imports.internal.ImportService;
import com.appsmith.server.repositories.GitDeployKeysRepository;
import com.appsmith.server.services.AnalyticsService;

View File

@ -6,11 +6,11 @@ import com.appsmith.server.applications.base.ApplicationService;
import com.appsmith.server.configurations.EmailConfig;
import com.appsmith.server.datasources.base.DatasourceService;
import com.appsmith.server.exports.internal.ExportService;
import com.appsmith.server.git.autocommit.helpers.GitAutoCommitHelper;
import com.appsmith.server.helpers.GitFileUtils;
import com.appsmith.server.helpers.GitPrivateRepoHelper;
import com.appsmith.server.helpers.RedisUtils;
import com.appsmith.server.helpers.ResponseUtils;
import com.appsmith.server.helpers.ce.autocommit.GitAutoCommitHelper;
import com.appsmith.server.imports.internal.ImportService;
import com.appsmith.server.newactions.base.NewActionService;
import com.appsmith.server.newpages.base.NewPageService;

View File

@ -1,5 +0,0 @@
package com.appsmith.server.solutions;
import com.appsmith.server.solutions.ce.AutoCommitEventHandlerCE;
public interface AutoCommitEventHandler extends AutoCommitEventHandlerCE {}

View File

@ -15,11 +15,11 @@ import com.appsmith.server.domains.GitProfile;
import com.appsmith.server.domains.Layout;
import com.appsmith.server.domains.NewPage;
import com.appsmith.server.dtos.ApplicationJson;
import com.appsmith.server.dtos.AutoCommitTriggerDTO;
import com.appsmith.server.dtos.PageDTO;
import com.appsmith.server.git.autocommit.helpers.AutoCommitEligibilityHelper;
import com.appsmith.server.helpers.DSLMigrationUtils;
import com.appsmith.server.helpers.GitPrivateRepoHelper;
import com.appsmith.server.helpers.ce.autocommit.AutoCommitEligibilityHelper;
import com.appsmith.server.helpers.ce.autocommit.AutoCommitTriggerDTO;
import com.appsmith.server.migrations.JsonSchemaMigration;
import com.appsmith.server.migrations.JsonSchemaVersions;
import com.appsmith.server.newpages.base.NewPageService;
@ -55,7 +55,7 @@ import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import static com.appsmith.server.solutions.ce.AutoCommitEventHandlerCEImpl.AUTO_COMMIT_MSG_FORMAT;
import static com.appsmith.server.git.AutoCommitEventHandlerCEImpl.AUTO_COMMIT_MSG_FORMAT;
import static java.lang.Boolean.FALSE;
import static java.lang.Boolean.TRUE;
import static org.assertj.core.api.Assertions.assertThat;

View File

@ -14,6 +14,8 @@ import com.appsmith.server.dtos.ApplicationJson;
import com.appsmith.server.dtos.PageDTO;
import com.appsmith.server.events.AutoCommitEvent;
import com.appsmith.server.featureflags.CachedFeatures;
import com.appsmith.server.git.AutoCommitEventHandler;
import com.appsmith.server.git.AutoCommitEventHandlerImpl;
import com.appsmith.server.helpers.CommonGitFileUtils;
import com.appsmith.server.helpers.DSLMigrationUtils;
import com.appsmith.server.helpers.GitFileUtils;
@ -22,8 +24,6 @@ import com.appsmith.server.migrations.JsonSchemaMigration;
import com.appsmith.server.migrations.JsonSchemaVersions;
import com.appsmith.server.services.AnalyticsService;
import com.appsmith.server.services.FeatureFlagService;
import com.appsmith.server.solutions.AutoCommitEventHandler;
import com.appsmith.server.solutions.AutoCommitEventHandlerImpl;
import com.appsmith.server.testhelpers.git.GitFileSystemTestHelper;
import lombok.extern.slf4j.Slf4j;
import net.minidev.json.JSONObject;
@ -54,7 +54,7 @@ import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import static com.appsmith.server.solutions.ce.AutoCommitEventHandlerCEImpl.AUTO_COMMIT_MSG_FORMAT;
import static com.appsmith.server.git.AutoCommitEventHandlerCEImpl.AUTO_COMMIT_MSG_FORMAT;
import static java.lang.Boolean.FALSE;
import static java.lang.Boolean.TRUE;
import static org.assertj.core.api.Assertions.assertThat;

View File

@ -1,4 +1,4 @@
package com.appsmith.server.helpers.ce.autocommit;
package com.appsmith.server.git.autocommit.helpers;
import com.appsmith.external.dtos.ModifiedResources;
import com.appsmith.external.enums.FeatureFlagEnum;
@ -8,6 +8,7 @@ import com.appsmith.server.domains.GitArtifactMetadata;
import com.appsmith.server.domains.Layout;
import com.appsmith.server.domains.Theme;
import com.appsmith.server.dtos.ApplicationJson;
import com.appsmith.server.dtos.AutoCommitTriggerDTO;
import com.appsmith.server.dtos.PageDTO;
import com.appsmith.server.helpers.CommonGitFileUtils;
import com.appsmith.server.helpers.DSLMigrationUtils;

View File

@ -1,4 +1,4 @@
package com.appsmith.server.helpers.ce.autocommit;
package com.appsmith.server.git.autocommit.helpers;
import com.appsmith.external.enums.FeatureFlagEnum;
import com.appsmith.server.acl.AclPermission;
@ -10,13 +10,13 @@ import com.appsmith.server.domains.GitAuth;
import com.appsmith.server.domains.GitProfile;
import com.appsmith.server.dtos.AutoCommitProgressDTO;
import com.appsmith.server.events.AutoCommitEvent;
import com.appsmith.server.git.AutoCommitEventHandler;
import com.appsmith.server.helpers.GitPrivateRepoHelper;
import com.appsmith.server.helpers.RedisUtils;
import com.appsmith.server.services.CommonGitService;
import com.appsmith.server.services.FeatureFlagService;
import com.appsmith.server.services.UserDataService;
import com.appsmith.server.solutions.ApplicationPermission;
import com.appsmith.server.solutions.AutoCommitEventHandler;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.jgit.lib.BranchTrackingStatus;
import org.junit.jupiter.api.AfterEach;