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/is 399 ggs create file #892

Merged
merged 17 commits into from
Aug 15, 2023
Merged

Conversation

alexanderleegs
Copy link
Contributor

@alexanderleegs alexanderleegs commented Aug 11, 2023

Problem

This PR introduces creates to our GGS solution. Resolves IS-399. This PR also modifies checks for the existence of paths to use gitFilePathStats instead of fs.existsSync.

Features:

  • Refactored safeExistsSync calls in clone and isValidGitRepo to use getFilePathStats instead
  • Create operation supported for GGS

Future work:

  • Verify image creation - pending image retrieval PR

@alexanderleegs alexanderleegs force-pushed the feat/is-399-ggs-create-file branch from 95a7509 to 3b0a52b Compare August 14, 2023 01:43
@alexanderleegs alexanderleegs marked this pull request as ready for review August 14, 2023 02:00
@alexanderleegs alexanderleegs requested a review from a team August 14, 2023 02:01
src/services/db/GitFileSystemService.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/services/db/GitFileSystemService.ts Outdated Show resolved Hide resolved
src/services/db/GitFileSystemService.ts Outdated Show resolved Hide resolved
src/services/db/RepoService.ts Show resolved Hide resolved
@alexanderleegs alexanderleegs requested a review from dcshzj August 14, 2023 05:22
src/services/db/GitFileSystemService.ts Show resolved Hide resolved
src/services/db/GitFileSystemService.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/services/db/GitFileSystemService.ts Show resolved Hide resolved
src/services/db/RepoService.ts Outdated Show resolved Hide resolved
src/services/db/RepoService.ts Show resolved Hide resolved
src/services/db/__tests__/GitFileSystemService.spec.ts Outdated Show resolved Hide resolved
)

expect(result._unsafeUnwrapErr()).toBeInstanceOf(NotFoundError)
expect(result.isErr()).toBeTrue()
Copy link
Contributor

Choose a reason for hiding this comment

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

how about tests to ensure rollbacks are done correctly - i.e. when failures occur along one of the many steps in create flow

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 we actually only rollback in either the actual file creation, or when committing the change. I'm not entirely sure how to mock the fs call itself!

Copy link
Contributor

Choose a reason for hiding this comment

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

okay, let's focus on the manual testing for rollback and add this in later. I think @dcshzj added a mock-fs library into the spec file which we can use possibly

@alexanderleegs alexanderleegs force-pushed the feat/is-399-ggs-create-file branch from f0dd458 to c4a9ab6 Compare August 15, 2023 02:55
@alexanderleegs alexanderleegs merged commit 6add98c into develop Aug 15, 2023
alexanderleegs added a commit that referenced this pull request Aug 15, 2023
* IS-401: Write extend repo service to support delete files folders (#894)

* feat: base code for delete file

* feat: add base delete directory steps

* feat: refactor into one delete function

* feat: split RepoService delete into two

* fix: remove unused imports

* feat: update return types

* fix: BDS tests

* feat: tests for delete in RepoService

* fix: remove update tree function for ggs flow

* feat: add tests for GFS

* feat: add tests for delete

* feat: add check for latest commit

* fix: uncomment push

* fix: add log

* feat: add tests

* Feat/is 399 ggs create file (#892)

* refactor: safeExistsSync

* chore: upgrade js-base64

* feat: add create methods

* test: add tests

* refactor: remove safeExistsSync and use getFilePathStats instead

* test: add tests for rollback

* feat: push on creation

* chore: update missing import

* chore: change to pass arguments directly

* chore: replace return type with GitCommitResult

* fix: remove unnecessary maps

* fix: swap returned error on creating file

* chore: remove unused import

* fix: handle stats from retrieving directory info

* nit: swap return from empty string to boolean

* chore: improve log statement

* fix: update assertion of error

* feat: add optional force param to push

* feat: add rollback functionality for whitelisted ggs sites

* fix: rebase errors

* fix: use false as default for isForce

---------

Co-authored-by: Harish <harish@open.gov.sg>
@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.

3 participants