Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1414,6 +1414,18 @@ private Mono<Ref> resetToLastCommit(Git git) {
.subscribeOn(scheduler);
}

/**
* reset to last commit on the current branch itself but doesn't checkout to any specific branch
* @param repoSuffix suffixedPath used to generate the base repo path this includes workspaceId, defaultAppId, repoName
* @return a boolean whether the operation was successfull or not
*/
public Mono<Boolean> resetToLastCommit(Path repoSuffix) {
return Mono.using(
() -> Git.open(createRepoPath(repoSuffix).toFile()),
git -> this.resetToLastCommit(git).thenReturn(true).onErrorReturn(false),
Git::close);
}

public Mono<Boolean> resetToLastCommit(Path repoSuffix, String branchName) {
return Mono.using(
() -> Git.open(createRepoPath(repoSuffix).toFile()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,13 @@ Mono<String> fetchRemote(
*/
Mono<Boolean> resetToLastCommit(Path repoSuffix, String branchName) throws GitAPIException, IOException;

/**
* This method will reset the repo to last commit for the current branch on which it's present
* @param repoSuffix suffixedPath used to generate the base repo path this includes workspaceId, defaultAppId, repoName
* @return success status
*/
Mono<Boolean> resetToLastCommit(Path repoSuffix);

/**
*
* @param repoSuffix suffixedPath used to generate the base repo path this includes workspaceId, defaultAppId, repoName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ protected Mono<? extends Artifact> createReference(
new AppsmithException(
AppsmithError.GIT_ACTION_FAILED,
"ref creation",
"either ref name is already exists or it doesn't meet naming criteria, or the artifact is not in a publishable state"));
"either ref name already exists or it doesn't meet naming criteria, or the artifact is not in a publishable state"));
}

Mono<? extends Artifact> newArtifactFromSourceMono = generateArtifactForRefCreation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,18 @@ public void setRepositoryDetailsInGitArtifactMetadata(
@Override
public Mono<? extends ArtifactExchangeJson> reconstructArtifactJsonFromGitRepository(
ArtifactJsonTransformationDTO artifactJsonTransformationDTO) {
return commonGitFileUtils.constructArtifactExchangeJsonFromGitRepositoryWithAnalytics(
artifactJsonTransformationDTO);
GitArtifactHelper<?> gitArtifactHelper =
gitArtifactHelperResolver.getArtifactHelper(artifactJsonTransformationDTO.getArtifactType());

Path repoSuffix = gitArtifactHelper.getRepoSuffixPath(
artifactJsonTransformationDTO.getWorkspaceId(),
artifactJsonTransformationDTO.getBaseArtifactId(),
artifactJsonTransformationDTO.getRepoName());

return fsGitHandler
.resetToLastCommit(repoSuffix)
.then(commonGitFileUtils.constructArtifactExchangeJsonFromGitRepositoryWithAnalytics(
artifactJsonTransformationDTO));
}
Comment on lines +278 to 290
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Handle possible reset failures.

resetToLastCommit(repoSuffix) may fail and return false. Consider explicitly handling or logging this result before proceeding to construct the artifact JSON to avoid potential inconsistencies.


@Override
Expand Down