chore: analytics for GIT FS (#32302)

This commit is contained in:
Manish Kumar 2024-04-02 20:55:19 +05:30 committed by GitHub
parent 12e36c97e9
commit d0162013f6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
18 changed files with 160 additions and 60 deletions

View File

@ -64,11 +64,11 @@ import java.util.Set;
import java.util.regex.Pattern;
import java.util.stream.Stream;
import static com.appsmith.external.constants.GitConstants.ACTION_COLLECTION_LIST;
import static com.appsmith.external.constants.GitConstants.ACTION_LIST;
import static com.appsmith.external.constants.GitConstants.CUSTOM_JS_LIB_LIST;
import static com.appsmith.external.constants.GitConstants.NAME_SEPARATOR;
import static com.appsmith.external.constants.GitConstants.PAGE_LIST;
import static com.appsmith.external.git.constants.GitConstants.ACTION_COLLECTION_LIST;
import static com.appsmith.external.git.constants.GitConstants.ACTION_LIST;
import static com.appsmith.external.git.constants.GitConstants.CUSTOM_JS_LIB_LIST;
import static com.appsmith.external.git.constants.GitConstants.NAME_SEPARATOR;
import static com.appsmith.external.git.constants.GitConstants.PAGE_LIST;
import static com.appsmith.git.constants.GitDirectories.ACTION_COLLECTION_DIRECTORY;
import static com.appsmith.git.constants.GitDirectories.ACTION_DIRECTORY;
import static com.appsmith.git.constants.GitDirectories.DATASOURCE_DIRECTORY;

View File

@ -3,6 +3,7 @@ package com.appsmith.git.service;
import com.appsmith.external.git.GitExecutor;
import com.appsmith.git.configurations.GitServiceConfig;
import com.appsmith.git.service.ce.GitExecutorCEImpl;
import io.micrometer.observation.ObservationRegistry;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -10,7 +11,7 @@ import org.springframework.stereotype.Component;
@Slf4j
public class GitExecutorImpl extends GitExecutorCEImpl implements GitExecutor {
public GitExecutorImpl(GitServiceConfig gitServiceConfig) {
super(gitServiceConfig);
public GitExecutorImpl(GitServiceConfig gitServiceConfig, ObservationRegistry observationRegistry) {
super(gitServiceConfig, observationRegistry);
}
}

View File

@ -7,6 +7,7 @@ import com.appsmith.external.dtos.GitLogDTO;
import com.appsmith.external.dtos.GitStatusDTO;
import com.appsmith.external.dtos.MergeStatusDTO;
import com.appsmith.external.git.GitExecutor;
import com.appsmith.external.git.constants.GitSpans;
import com.appsmith.external.helpers.Stopwatch;
import com.appsmith.git.configurations.GitServiceConfig;
import com.appsmith.git.constants.AppsmithBotAsset;
@ -16,6 +17,7 @@ import com.appsmith.git.constants.GitDirectories;
import com.appsmith.git.helpers.RepositoryHelper;
import com.appsmith.git.helpers.SshTransportConfigCallback;
import com.appsmith.git.helpers.StopwatchHelpers;
import io.micrometer.observation.ObservationRegistry;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.jgit.api.CreateBranchCommand;
@ -40,6 +42,7 @@ import org.eclipse.jgit.transport.RefSpec;
import org.eclipse.jgit.util.StringUtils;
import org.springframework.stereotype.Component;
import org.springframework.util.FileSystemUtils;
import reactor.core.observability.micrometer.Micrometer;
import reactor.core.publisher.Mono;
import reactor.core.scheduler.Scheduler;
import reactor.core.scheduler.Schedulers;
@ -60,7 +63,11 @@ import java.util.List;
import java.util.Optional;
import java.util.Set;
import static com.appsmith.external.git.constants.GitConstants.GitMetricConstants.CHECKOUT_REMOTE;
import static com.appsmith.external.git.constants.GitConstants.GitMetricConstants.HARD_RESET;
import static com.appsmith.git.constants.CommonConstants.FILE_MIGRATION_MESSAGE;
import static java.lang.Boolean.FALSE;
import static java.lang.Boolean.TRUE;
@RequiredArgsConstructor
@Component
@ -71,6 +78,8 @@ public class GitExecutorCEImpl implements GitExecutor {
private final GitServiceConfig gitServiceConfig;
protected final ObservationRegistry observationRegistry;
public static final DateTimeFormatter ISO_FORMATTER =
DateTimeFormatter.ISO_INSTANT.withZone(ZoneId.from(ZoneOffset.UTC));
@ -104,7 +113,7 @@ public class GitExecutorCEImpl implements GitExecutor {
return Mono.fromCallable(() -> {
log.debug("Trying to commit to local repo path, {}", path);
Path repoPath = path;
if (Boolean.TRUE.equals(isSuffixedPath)) {
if (TRUE.equals(isSuffixedPath)) {
repoPath = createRepoPath(repoPath);
}
Stopwatch processStopwatch =
@ -130,6 +139,8 @@ public class GitExecutorCEImpl implements GitExecutor {
}
})
.timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS))
.name(GitSpans.FILE_SYSTEM_COMMIT.getEventName())
.tap(Micrometer.observation(observationRegistry))
.subscribeOn(scheduler);
}
@ -232,6 +243,8 @@ public class GitExecutorCEImpl implements GitExecutor {
}
})
.timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS))
.name(GitSpans.FILE_SYSTEM_PUSH.getEventName())
.tap(Micrometer.observation(observationRegistry))
.subscribeOn(scheduler);
}
@ -272,6 +285,8 @@ public class GitExecutorCEImpl implements GitExecutor {
return branchName;
})
.timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS))
.name(GitSpans.FILE_SYSTEM_CLONE_REPO.getEventName())
.tap(Micrometer.observation(observationRegistry))
.subscribeOn(scheduler);
}
@ -289,7 +304,7 @@ public class GitExecutorCEImpl implements GitExecutor {
try (Git git = Git.open(baseRepoPath.toFile())) {
// Create and checkout to new branch
git.checkout()
.setCreateBranch(Boolean.TRUE)
.setCreateBranch(TRUE)
.setName(branchName)
.setUpstreamMode(CreateBranchCommand.SetupUpstreamMode.TRACK)
.call();
@ -300,6 +315,8 @@ public class GitExecutorCEImpl implements GitExecutor {
}
})
.timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS))
.name(GitSpans.FILE_SYSTEM_CREATE_BRANCH.getEventName())
.tap(Micrometer.observation(observationRegistry))
.subscribeOn(scheduler);
}
@ -318,16 +335,18 @@ public class GitExecutorCEImpl implements GitExecutor {
// Create and checkout to new branch
List<String> deleteBranchList = git.branchDelete()
.setBranchNames(branchName)
.setForce(Boolean.TRUE)
.setForce(TRUE)
.call();
processStopwatch.stopAndLogTimeInMillis();
if (deleteBranchList.isEmpty()) {
return Boolean.FALSE;
}
return Boolean.TRUE;
return TRUE;
}
})
.timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS))
.name(GitSpans.FILE_SYSTEM_DELETE_BRANCH.getEventName())
.tap(Micrometer.observation(observationRegistry))
.subscribeOn(scheduler);
}
@ -345,7 +364,7 @@ public class GitExecutorCEImpl implements GitExecutor {
try (Git git = Git.open(baseRepoPath.toFile())) {
if (StringUtils.equalsIgnoreCase(
branchName, git.getRepository().getBranch())) {
return Boolean.TRUE;
return TRUE;
}
// Create and checkout to new branch
String checkedOutBranch = git.checkout()
@ -361,6 +380,9 @@ public class GitExecutorCEImpl implements GitExecutor {
}
})
.timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS))
.tag(CHECKOUT_REMOTE, FALSE.toString())
.name(GitSpans.FILE_SYSTEM_CHECKOUT_BRANCH.getEventName())
.tap(Micrometer.observation(observationRegistry))
.subscribeOn(scheduler);
}
@ -421,6 +443,8 @@ public class GitExecutorCEImpl implements GitExecutor {
}
})
.timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS))
.name(GitSpans.FILE_SYSTEM_PULL.getEventName())
.tap(Micrometer.observation(observationRegistry))
.subscribeOn(scheduler);
}
}
@ -536,6 +560,8 @@ public class GitExecutorCEImpl implements GitExecutor {
})
.timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS))
.flatMap(response -> response)
.name(GitSpans.FILE_SYSTEM_STATUS.getEventName())
.tap(Micrometer.observation(observationRegistry))
.subscribeOn(scheduler);
}
@ -656,6 +682,8 @@ public class GitExecutorCEImpl implements GitExecutor {
}
})
.timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS))
.name(GitSpans.FILE_SYSTEM_MERGE.getEventName())
.tap(Micrometer.observation(observationRegistry))
.subscribeOn(scheduler);
}
@ -669,12 +697,12 @@ public class GitExecutorCEImpl implements GitExecutor {
boolean isFetchAll) {
Stopwatch processStopwatch =
StopwatchHelpers.startStopwatch(repoSuffix, AnalyticsEvents.GIT_FETCH.getEventName());
Path repoPath = Boolean.TRUE.equals(isRepoPath) ? repoSuffix : createRepoPath(repoSuffix);
Path repoPath = TRUE.equals(isRepoPath) ? repoSuffix : createRepoPath(repoSuffix);
return Mono.fromCallable(() -> {
TransportConfigCallback config = new SshTransportConfigCallback(privateKey, publicKey);
try (Git git = Git.open(repoPath.toFile())) {
String fetchMessages;
if (Boolean.TRUE.equals(isFetchAll)) {
if (TRUE.equals(isFetchAll)) {
fetchMessages = git.fetch()
.setRemoveDeletedRefs(true)
.setTransportConfigCallback(config)
@ -699,6 +727,8 @@ public class GitExecutorCEImpl implements GitExecutor {
return Mono.error(error);
})
.timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS))
.name(GitSpans.FILE_SYSTEM_FETCH_REMOTE.getEventName())
.tap(Micrometer.observation(observationRegistry))
.subscribeOn(scheduler);
}
@ -793,7 +823,7 @@ public class GitExecutorCEImpl implements GitExecutor {
try (Git git = Git.open(baseRepoPath.toFile())) {
// Create and checkout to new branch
git.checkout()
.setCreateBranch(Boolean.TRUE)
.setCreateBranch(TRUE)
.setName(branchName)
.setUpstreamMode(CreateBranchCommand.SetupUpstreamMode.TRACK)
.setStartPoint("origin/" + branchName)
@ -807,6 +837,9 @@ public class GitExecutorCEImpl implements GitExecutor {
}
})
.timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS))
.tag(CHECKOUT_REMOTE, TRUE.toString())
.name(GitSpans.FILE_SYSTEM_CHECKOUT_BRANCH.getEventName())
.tap(Micrometer.observation(observationRegistry))
.subscribeOn(scheduler);
}
@ -839,6 +872,9 @@ public class GitExecutorCEImpl implements GitExecutor {
return ref;
})
.timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS))
.tag(HARD_RESET, Boolean.FALSE.toString())
.name(GitSpans.FILE_SYSTEM_RESET.getEventName())
.tap(Micrometer.observation(observationRegistry))
.subscribeOn(scheduler);
}
@ -872,6 +908,9 @@ public class GitExecutorCEImpl implements GitExecutor {
return Mono.just(false);
})
.timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS))
.tag(HARD_RESET, TRUE.toString())
.name(GitSpans.FILE_SYSTEM_RESET.getEventName())
.tap(Micrometer.observation(observationRegistry))
.subscribeOn(scheduler);
}
@ -901,6 +940,8 @@ public class GitExecutorCEImpl implements GitExecutor {
}
})
.timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS))
.name(GitSpans.FILE_SYSTEM_REBASE.getEventName())
.tap(Micrometer.observation(observationRegistry))
.subscribeOn(scheduler);
}
@ -912,6 +953,8 @@ public class GitExecutorCEImpl implements GitExecutor {
}
})
.timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS))
.name(GitSpans.FILE_SYSTEM_BRANCH_TRACK.getEventName())
.tap(Micrometer.observation(observationRegistry))
.subscribeOn(scheduler);
}
}

View File

@ -1,5 +0,0 @@
package com.appsmith.external.constants;
import com.appsmith.external.constants.ce.GitConstantsCE;
public class GitConstants extends GitConstantsCE {}

View File

@ -2,4 +2,9 @@ package com.appsmith.external.constants.spans;
public class BaseSpan {
public static final String APPSMITH_SPAN_PREFIX = "appsmith.";
/**
* This prefix is for all the git flows
*/
public static final String GIT_SPAN_PREFIX = "git.";
}

View File

@ -0,0 +1,8 @@
package com.appsmith.external.git.constants;
import com.appsmith.external.git.constants.ce.GitConstantsCE;
public class GitConstants extends GitConstantsCE {
public class GitMetricConstants extends GitMetricConstantsCE {}
}

View File

@ -0,0 +1,36 @@
package com.appsmith.external.git.constants;
import java.util.Locale;
import static com.appsmith.external.constants.spans.BaseSpan.APPSMITH_SPAN_PREFIX;
import static com.appsmith.external.constants.spans.BaseSpan.GIT_SPAN_PREFIX;
public enum GitSpans {
FILE_SYSTEM_CLONE_REPO,
FILE_SYSTEM_STATUS,
FILE_SYSTEM_PULL,
FILE_SYSTEM_BRANCH_TRACK,
ADD_FILE_LOCK,
RELEASE_FILE_LOCK,
FILE_SYSTEM_COMMIT,
FILE_SYSTEM_CHECKOUT_BRANCH,
FILE_SYSTEM_CREATE_BRANCH,
FILE_SYSTEM_DELETE_BRANCH,
FILE_SYSTEM_CREATE_REPO,
FILE_SYSTEM_RESET,
FILE_SYSTEM_MERGE,
FILE_SYSTEM_REBASE,
FILE_SYSTEM_PUSH,
FILE_SYSTEM_FETCH_REMOTE,
STATUS,
COMMIT;
private final String eventName;
GitSpans() {
this.eventName = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + name().toLowerCase(Locale.ROOT);
}
public String getEventName() {
return this.eventName;
}
}

View File

@ -1,4 +1,4 @@
package com.appsmith.external.constants.ce;
package com.appsmith.external.git.constants.ce;
public class GitConstantsCE {
// This will be used as a key separator for action and jsobjects name
@ -21,4 +21,9 @@ public class GitConstantsCE {
public static final String GIT_PROFILE_ERROR = "Unable to find git author configuration for logged-in user. You can"
+ " set up a git profile from the user profile section.";
public class GitMetricConstantsCE {
public static final String CHECKOUT_REMOTE = "checkout-remote";
public static final String HARD_RESET = "hard-reset";
}
}

View File

@ -22,7 +22,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
import static com.appsmith.external.constants.GitConstants.NAME_SEPARATOR;
import static com.appsmith.external.git.constants.GitConstants.NAME_SEPARATOR;
import static com.appsmith.server.constants.ResourceModes.EDIT;
import static com.appsmith.server.constants.ResourceModes.VIEW;

View File

@ -27,7 +27,7 @@ import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static com.appsmith.external.constants.ce.GitConstantsCE.NAME_SEPARATOR;
import static com.appsmith.external.git.constants.GitConstants.NAME_SEPARATOR;
import static com.appsmith.external.helpers.AppsmithBeanUtils.copyProperties;
import static com.appsmith.server.constants.ce.FieldNameCE.ACTION_COLLECTION_LIST;
import static com.appsmith.server.constants.ce.FieldNameCE.ACTION_LIST;

View File

@ -57,7 +57,7 @@ import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static com.appsmith.external.constants.GitConstants.NAME_SEPARATOR;
import static com.appsmith.external.git.constants.GitConstants.NAME_SEPARATOR;
import static com.appsmith.external.helpers.AppsmithBeanUtils.copyNestedNonNullProperties;
import static com.appsmith.external.helpers.AppsmithBeanUtils.copyProperties;
import static com.appsmith.server.constants.FieldName.ACTION_COLLECTION_LIST;

View File

@ -22,7 +22,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
import static com.appsmith.external.constants.GitConstants.NAME_SEPARATOR;
import static com.appsmith.external.git.constants.GitConstants.NAME_SEPARATOR;
import static com.appsmith.server.constants.ResourceModes.EDIT;
import static com.appsmith.server.constants.ResourceModes.VIEW;
import static com.appsmith.server.helpers.ImportExportUtils.sanitizeDatasourceInActionDTO;

View File

@ -62,10 +62,10 @@ import java.util.Optional;
import java.util.concurrent.TimeoutException;
import java.util.stream.Collectors;
import static com.appsmith.external.constants.ce.GitConstantsCE.DEFAULT_COMMIT_MESSAGE;
import static com.appsmith.external.constants.ce.GitConstantsCE.EMPTY_COMMIT_ERROR_MESSAGE;
import static com.appsmith.external.constants.ce.GitConstantsCE.GIT_CONFIG_ERROR;
import static com.appsmith.external.constants.ce.GitConstantsCE.GIT_PROFILE_ERROR;
import static com.appsmith.external.git.constants.GitConstants.DEFAULT_COMMIT_MESSAGE;
import static com.appsmith.external.git.constants.GitConstants.EMPTY_COMMIT_ERROR_MESSAGE;
import static com.appsmith.external.git.constants.GitConstants.GIT_CONFIG_ERROR;
import static com.appsmith.external.git.constants.GitConstants.GIT_PROFILE_ERROR;
import static com.appsmith.server.constants.ArtifactType.APPLICATION;
import static com.appsmith.server.constants.SerialiseArtifactObjective.VERSION_CONTROL;
import static com.appsmith.server.constants.ce.FieldNameCE.DEFAULT;

View File

@ -7,6 +7,7 @@ import com.appsmith.external.dtos.GitLogDTO;
import com.appsmith.external.dtos.GitStatusDTO;
import com.appsmith.external.dtos.MergeStatusDTO;
import com.appsmith.external.git.GitExecutor;
import com.appsmith.external.git.constants.GitSpans;
import com.appsmith.external.models.Datasource;
import com.appsmith.external.models.DatasourceStorage;
import com.appsmith.git.service.GitExecutorImpl;
@ -100,12 +101,14 @@ import java.util.stream.Collectors;
import static com.appsmith.external.constants.AnalyticsEvents.GIT_ADD_PROTECTED_BRANCH;
import static com.appsmith.external.constants.AnalyticsEvents.GIT_REMOVE_PROTECTED_BRANCH;
import static com.appsmith.external.constants.GitConstants.CONFLICTED_SUCCESS_MESSAGE;
import static com.appsmith.external.constants.GitConstants.DEFAULT_COMMIT_MESSAGE;
import static com.appsmith.external.constants.GitConstants.EMPTY_COMMIT_ERROR_MESSAGE;
import static com.appsmith.external.constants.GitConstants.GIT_CONFIG_ERROR;
import static com.appsmith.external.constants.GitConstants.GIT_PROFILE_ERROR;
import static com.appsmith.external.constants.GitConstants.MERGE_CONFLICT_BRANCH_NAME;
import static com.appsmith.external.git.constants.GitConstants.CONFLICTED_SUCCESS_MESSAGE;
import static com.appsmith.external.git.constants.GitConstants.DEFAULT_COMMIT_MESSAGE;
import static com.appsmith.external.git.constants.GitConstants.EMPTY_COMMIT_ERROR_MESSAGE;
import static com.appsmith.external.git.constants.GitConstants.GIT_CONFIG_ERROR;
import static com.appsmith.external.git.constants.GitConstants.GIT_PROFILE_ERROR;
import static com.appsmith.external.git.constants.GitConstants.MERGE_CONFLICT_BRANCH_NAME;
import static com.appsmith.external.git.constants.GitSpans.COMMIT;
import static com.appsmith.external.git.constants.GitSpans.STATUS;
import static com.appsmith.git.constants.AppsmithBotAsset.APPSMITH_BOT_USERNAME;
import static com.appsmith.server.constants.ArtifactType.APPLICATION;
import static com.appsmith.server.constants.FieldName.DEFAULT;
@ -113,6 +116,7 @@ import static com.appsmith.server.constants.SerialiseArtifactObjective.VERSION_C
import static com.appsmith.server.helpers.DefaultResourcesUtils.createDefaultIdsOrUpdateWithGivenResourceIds;
import static com.appsmith.server.helpers.GitUtils.MAX_RETRIES;
import static com.appsmith.server.helpers.GitUtils.RETRY_DELAY;
import static java.lang.Boolean.TRUE;
import static org.apache.commons.lang.ObjectUtils.defaultIfNull;
/**
@ -227,7 +231,7 @@ public class GitServiceCEImpl implements GitServiceCE {
if (DEFAULT.equals(defaultApplicationId)) {
gitProfile.setUseGlobalProfile(null);
} else if (!Boolean.TRUE.equals(gitProfile.getUseGlobalProfile())) {
} else if (!TRUE.equals(gitProfile.getUseGlobalProfile())) {
gitProfile.setUseGlobalProfile(Boolean.FALSE);
}
@ -427,7 +431,7 @@ public class GitServiceCEImpl implements GitServiceCE {
})
.flatMap(application -> {
GitArtifactMetadata gitData = application.getGitApplicationMetadata();
if (Boolean.TRUE.equals(isFileLock)) {
if (TRUE.equals(isFileLock)) {
return addFileLock(gitData.getDefaultApplicationId()).then(Mono.just(application));
}
return Mono.just(application);
@ -445,7 +449,7 @@ public class GitServiceCEImpl implements GitServiceCE {
.flatMap(isPrivate -> {
// Check the repo limit if the visibility status is updated, or it is private
if (!isPrivate.equals(defaultGitMetadata.getIsRepoPrivate())
|| isPrivate.equals(Boolean.TRUE)) {
|| isPrivate.equals(TRUE)) {
defaultGitMetadata.setIsRepoPrivate(isPrivate);
defaultApplication.setGitApplicationMetadata(defaultGitMetadata);
return applicationService
@ -574,7 +578,7 @@ public class GitServiceCEImpl implements GitServiceCE {
String commitStatus = tuple.getT1();
result.append(commitStatus);
if (Boolean.TRUE.equals(commitDTO.getDoPush())) {
if (TRUE.equals(commitDTO.getDoPush())) {
// Push flow
result.append(".\nPush Result : ");
return pushApplication(childApplication.getId(), false, false)
@ -606,7 +610,7 @@ public class GitServiceCEImpl implements GitServiceCE {
.update(childApplication.getId(), update)
// Release the file lock on git repo
.flatMap(application -> {
if (Boolean.TRUE.equals(isFileLock)) {
if (TRUE.equals(isFileLock)) {
return releaseFileLock(childApplication
.getGitApplicationMetadata()
.getDefaultApplicationId());
@ -621,8 +625,7 @@ public class GitServiceCEImpl implements GitServiceCE {
childApplication.getGitApplicationMetadata().getIsRepoPrivate(),
isSystemGenerated))
.thenReturn(status)
.tag("gitCommit", defaultApplicationId)
.name(AnalyticsEvents.GIT_COMMIT.getEventName())
.name(COMMIT.getEventName())
.tap(Micrometer.observation(observationRegistry));
});
@ -872,7 +875,7 @@ public class GitServiceCEImpl implements GitServiceCE {
if (!application.getPages().isEmpty()) {
defaultPageId = application.getPages().stream()
.filter(applicationPage ->
applicationPage.getIsDefault().equals(Boolean.TRUE))
applicationPage.getIsDefault().equals(TRUE))
.collect(Collectors.toList())
.get(0)
.getId();
@ -906,7 +909,7 @@ public class GitServiceCEImpl implements GitServiceCE {
GitProfile profile = userData.getGitProfileByKey(defaultApplicationId);
if (profile == null
|| StringUtils.isEmptyOrNull(profile.getAuthorName())
|| Boolean.TRUE.equals(profile.getUseGlobalProfile())) {
|| TRUE.equals(profile.getUseGlobalProfile())) {
profile = userData.getGitProfileByKey(DEFAULT);
}
@ -1009,7 +1012,7 @@ public class GitServiceCEImpl implements GitServiceCE {
});
})
.flatMap(application -> {
if (Boolean.TRUE.equals(isFileLock)) {
if (TRUE.equals(isFileLock)) {
return addFileLock(
application.getGitApplicationMetadata().getDefaultApplicationId())
.map(status -> application);
@ -1069,7 +1072,7 @@ public class GitServiceCEImpl implements GitServiceCE {
.flatMap(tuple -> {
String pushStatus = tuple.getT1();
Application application = tuple.getT2();
if (Boolean.TRUE.equals(isFileLock)) {
if (TRUE.equals(isFileLock)) {
return releaseFileLock(
application.getGitApplicationMetadata().getDefaultApplicationId())
.map(status -> tuple);
@ -1545,7 +1548,7 @@ public class GitServiceCEImpl implements GitServiceCE {
.flatMap(application1 -> addAnalyticsForGitOperation(
AnalyticsEvents.GIT_CHECKOUT_REMOTE_BRANCH,
application1,
Boolean.TRUE.equals(application1
TRUE.equals(application1
.getGitApplicationMetadata()
.getIsRepoPrivate())))
.map(responseUtils::updateApplicationWithDefaultResources)
@ -1558,7 +1561,7 @@ public class GitServiceCEImpl implements GitServiceCE {
}
private Mono<Application> publishAndOrGetApplication(String applicationId, boolean publish) {
if (Boolean.TRUE.equals(publish)) {
if (TRUE.equals(publish)) {
return applicationPageService
.publish(applicationId, true)
// Get application here to decrypt the git private key if present
@ -1779,7 +1782,7 @@ public class GitServiceCEImpl implements GitServiceCE {
.flatMap(rootApplication -> {
Path repoPath = getRepoPath(rootApplication);
Mono<String> defaultBranchMono;
if (Boolean.TRUE.equals(pruneBranches) && syncDefaultBranchWithRemote) {
if (TRUE.equals(pruneBranches) && syncDefaultBranchWithRemote) {
defaultBranchMono = syncDefaultBranchNameFromRemote(repoPath, rootApplication);
} else {
defaultBranchMono =
@ -1825,7 +1828,7 @@ public class GitServiceCEImpl implements GitServiceCE {
.flatMap(objects -> {
GitArtifactMetadata gitArtifactMetadata = rootApp.getGitApplicationMetadata();
if (Boolean.TRUE.equals(pruneBranches)) {
if (TRUE.equals(pruneBranches)) {
return gitExecutor
.fetchRemote(
repoPath,
@ -1992,8 +1995,7 @@ public class GitServiceCEImpl implements GitServiceCE {
throwable);
return Mono.error(new AppsmithException(AppsmithError.GIT_GENERIC_ERROR, throwable.getMessage()));
})
.tag("gitStatus", defaultApplicationId)
.name(AnalyticsEvents.GIT_STATUS.getEventName())
.name(STATUS.getEventName())
.tap(Micrometer.observation(observationRegistry));
return Mono.zip(statusMono, sessionUserService.getCurrentUser(), branchedAppMono)
@ -2261,7 +2263,7 @@ public class GitServiceCEImpl implements GitServiceCE {
ApplicationJson applicationJson = tuple.getT3();
MergeStatusDTO mergeStatusDTO = new MergeStatusDTO();
mergeStatusDTO.setStatus(tuple.getT1());
mergeStatusDTO.setMergeAble(Boolean.TRUE);
mergeStatusDTO.setMergeAble(TRUE);
// 4. Get the latest application mono with all the changes
return importService
@ -3271,11 +3273,16 @@ public class GitServiceCEImpl implements GitServiceCE {
.retryWhen(Retry.fixedDelay(MAX_RETRIES, RETRY_DELAY)
.onRetryExhaustedThrow((retryBackoffSpec, retrySignal) -> {
throw new AppsmithException(AppsmithError.GIT_FILE_IN_USE);
}));
}))
.name(GitSpans.ADD_FILE_LOCK.getEventName())
.tap(Micrometer.observation(observationRegistry));
}
private Mono<Boolean> releaseFileLock(String defaultApplicationId) {
return redisUtils.releaseFileLock(defaultApplicationId);
return redisUtils
.releaseFileLock(defaultApplicationId)
.name(GitSpans.RELEASE_FILE_LOCK.getEventName())
.tap(Micrometer.observation(observationRegistry));
}
@Override
@ -3354,7 +3361,7 @@ public class GitServiceCEImpl implements GitServiceCE {
if (autoCommitConfig.getEnabled()) {
autoCommitConfig.setEnabled(Boolean.FALSE);
} else {
autoCommitConfig.setEnabled(Boolean.TRUE);
autoCommitConfig.setEnabled(TRUE);
}
// need to call the setter because getter returns a default config if attribute is null
application.getGitApplicationMetadata().setAutoCommitConfig(autoCommitConfig);

View File

@ -35,7 +35,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import static com.appsmith.external.constants.GitConstants.PAGE_LIST;
import static com.appsmith.external.git.constants.GitConstants.PAGE_LIST;
import static com.appsmith.server.helpers.GitUtils.MAX_RETRIES;
import static com.appsmith.server.helpers.GitUtils.RETRY_DELAY;

View File

@ -95,7 +95,7 @@ import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import static com.appsmith.external.constants.GitConstants.NAME_SEPARATOR;
import static com.appsmith.external.git.constants.GitConstants.NAME_SEPARATOR;
import static com.appsmith.server.acl.AclPermission.MANAGE_APPLICATIONS;
import static com.appsmith.server.acl.AclPermission.MANAGE_PAGES;
import static com.appsmith.server.acl.AclPermission.READ_ACTIONS;

View File

@ -37,7 +37,7 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static com.appsmith.external.constants.GitConstants.NAME_SEPARATOR;
import static com.appsmith.external.git.constants.GitConstants.NAME_SEPARATOR;
import static org.assertj.core.api.Assertions.assertThat;
@ExtendWith(SpringExtension.class)

View File

@ -124,7 +124,7 @@ import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import static com.appsmith.external.constants.ce.GitConstantsCE.NAME_SEPARATOR;
import static com.appsmith.external.git.constants.ce.GitConstantsCE.NAME_SEPARATOR;
import static com.appsmith.server.acl.AclPermission.MANAGE_ACTIONS;
import static com.appsmith.server.acl.AclPermission.MANAGE_APPLICATIONS;
import static com.appsmith.server.acl.AclPermission.MANAGE_DATASOURCES;