Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(GGs): implement update operation #889

Merged
merged 14 commits into from
Aug 11, 2023
Merged

feat(GGs): implement update operation #889

merged 14 commits into from
Aug 11, 2023

Conversation

dcshzj
Copy link
Contributor

@dcshzj dcshzj commented Aug 10, 2023

Problem

Closes IS-400.

Solution

Breaking Changes

  • Yes - this PR contains breaking changes
  • No - this PR is backwards compatible

Features:

  • The update operation using the local file system is now supported.
  • In the event of an error, the file system may potentially be in an inconsistent state. A new rollback function was added to support resetting the file system to the last working state.
  • Pushes will happen asynchronously so that the user can continue working on the CMS while the backend pushes to GitHub.

Tests

  1. Unit tests
  2. E2E tests to verify that there is no regressions

Deploy Notes

None

@dcshzj dcshzj requested a review from a team August 10, 2023 03:51
@dcshzj dcshzj changed the title feat(GGs): Implement update operation feat(GGs): implement update operation Aug 10, 2023
src/errors/GitFileSystemNeedRollbackError.ts Outdated Show resolved Hide resolved
src/services/db/GitFileSystemService.ts Outdated Show resolved Hide resolved
src/services/db/GitFileSystemService.ts Show resolved Hide resolved
src/errors/GitFileSystemNeedRollbackError.ts Outdated Show resolved Hide resolved
src/services/db/GitFileSystemService.ts Outdated Show resolved Hide resolved
src/services/db/GitFileSystemService.ts Show resolved Hide resolved
logger.warn(`Rolling repo ${repoName} back to ${commitSha}`)
return ResultAsync.fromPromise(
this.git
.cwd(`${EFS_VOL_PATH}/${repoName}`)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: better to use path.join instead of template literals?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm I think same comment with Harish, mainly to keep the code consistent. I think we never really used path.join before, might be a discussion we should have team-wide.

filePath: string
): ResultAsync<fs.Stats, NotFoundError | GitFileSystemError> {
return ResultAsync.fromPromise(
fs.promises.stat(`${EFS_VOL_PATH}/${repoName}/${filePath}`),
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: better to use path.join instead of template literals?

.andThen(() =>
ResultAsync.fromPromise(
fs.promises.writeFile(
`${EFS_VOL_PATH}/${repoName}/${filePath}`,
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: use path.join

): Promise<GitCommitResult> {
if (this.isRepoWhitelisted(sessionData.siteName)) {
logger.info("Updating file in local Git file system")
const filePath = directoryName ? `${directoryName}/${fileName}` : fileName
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: path.join

Copy link
Contributor

@QiluXie QiluXie left a comment

Choose a reason for hiding this comment

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

lgtm with some non-blocking nit comments

@dcshzj dcshzj merged commit 8563580 into develop Aug 11, 2023
@mergify mergify bot deleted the feat/ggs-update branch August 11, 2023 10:19
@kishore03109 kishore03109 mentioned this pull request Aug 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants