From 05f1bbe698c26168f52a350d5e2389fba8640ff1 Mon Sep 17 00:00:00 2001
From: Kishore <42832651+kishore03109@users.noreply.github.com>
Date: Mon, 4 Dec 2023 06:21:33 +0800
Subject: [PATCH 1/5] feat(gitFileSystem): safer api
---
src/routes/formsg/formsgGGsRepair.ts | 2 +-
src/services/db/GitFileCommitService.ts | 361 +++++++++++-------------
src/services/db/GitFileSystemService.ts | 47 +--
3 files changed, 190 insertions(+), 220 deletions(-)
diff --git a/src/routes/formsg/formsgGGsRepair.ts b/src/routes/formsg/formsgGGsRepair.ts
index 6558acda5..869902145 100644
--- a/src/routes/formsg/formsgGGsRepair.ts
+++ b/src/routes/formsg/formsgGGsRepair.ts
@@ -230,7 +230,7 @@ ${syncedRepos.map((repo) => `
${repo}`)}
doesRepoNeedClone(repoName: string): ResultAsync {
return this.gitFileSystemService
- .isGitInitialized(repoName)
+ .isGitInitialized(repoName, true)
.andThen((isRepoInEfs) => {
if (isRepoInEfs) {
return errAsync(false)
diff --git a/src/services/db/GitFileCommitService.ts b/src/services/db/GitFileCommitService.ts
index d89b47cf2..e3710ec98 100644
--- a/src/services/db/GitFileCommitService.ts
+++ b/src/services/db/GitFileCommitService.ts
@@ -1,6 +1,8 @@
+import { okAsync } from "neverthrow"
+
import GithubSessionData from "@root/classes/GithubSessionData"
import UserWithSiteSessionData from "@root/classes/UserWithSiteSessionData"
-import { STAGING_BRANCH } from "@root/constants"
+import { STAGING_BRANCH, STAGING_LITE_BRANCH } from "@root/constants"
import logger from "@root/logger/logger"
import { GitCommitResult } from "@root/types/gitfilesystem"
import isFileAsset from "@root/utils/commit-utils"
@@ -14,14 +16,34 @@ import GitFileSystemService from "./GitFileSystemService"
* 2. Creates non-asset related commits to staging-lite
*/
export default class GitFileCommitService {
- private readonly STAGING_LITE_BRANCH = "staging-lite"
-
private readonly gitFileSystemService: GitFileSystemService
constructor(gitFileSystemService: GitFileSystemService) {
this.gitFileSystemService = gitFileSystemService
}
+ async pushToGithub(
+ sessionData: UserWithSiteSessionData,
+ shouldUpdateStagingLite: boolean
+ ) {
+ // We await the push to staging FIRST, and then push to staging-lite
+ // We don't want a case when staging lite updates but staging doesn't
+ const res = this.gitFileSystemService.push(
+ sessionData.siteName,
+ STAGING_BRANCH
+ )
+
+ if (shouldUpdateStagingLite) {
+ res.andThen(() =>
+ this.gitFileSystemService.push(
+ sessionData.siteName,
+ STAGING_LITE_BRANCH
+ )
+ )
+ }
+ await res
+ }
+
async create(
sessionData: UserWithSiteSessionData,
{
@@ -36,51 +58,43 @@ export default class GitFileCommitService {
isMedia?: boolean
}
): Promise<{ sha: string }> {
- const createPromises = [
- this.gitFileSystemService.create(
+ const stagingCreateResult = await this.gitFileSystemService.create(
+ sessionData.siteName,
+ sessionData.isomerUserId,
+ content,
+ directoryName,
+ fileName,
+ isMedia ? "base64" : "utf-8",
+ STAGING_BRANCH
+ )
+ const shouldUpdateStagingLite =
+ isReduceBuildTimesWhitelistedRepo(sessionData.growthbook) &&
+ !isFileAsset({ directoryName, fileName })
+
+ let stagingLiteCreateResult
+ if (shouldUpdateStagingLite) {
+ stagingLiteCreateResult = await this.gitFileSystemService.create(
sessionData.siteName,
sessionData.isomerUserId,
content,
directoryName,
fileName,
isMedia ? "base64" : "utf-8",
- STAGING_BRANCH
- ),
- ]
- const shouldUpdateStagingLite =
- isReduceBuildTimesWhitelistedRepo(sessionData.growthbook) &&
- !isFileAsset({ directoryName, fileName })
-
- if (shouldUpdateStagingLite) {
- createPromises.push(
- this.gitFileSystemService.create(
- sessionData.siteName,
- sessionData.isomerUserId,
- content,
- directoryName,
- fileName,
- isMedia ? "base64" : "utf-8",
- this.STAGING_LITE_BRANCH
- )
+ STAGING_LITE_BRANCH
)
}
- const [stagingCreateResult, stagingLiteCreateResult] = await Promise.all(
- createPromises
- )
if (stagingCreateResult.isErr()) {
throw stagingCreateResult.error
- } else if (shouldUpdateStagingLite && stagingLiteCreateResult.isErr()) {
+ } else if (
+ shouldUpdateStagingLite &&
+ stagingLiteCreateResult &&
+ stagingLiteCreateResult.isErr()
+ ) {
throw stagingLiteCreateResult.error
}
- this.gitFileSystemService.push(sessionData.siteName, STAGING_BRANCH)
- if (shouldUpdateStagingLite) {
- this.gitFileSystemService.push(
- sessionData.siteName,
- this.STAGING_LITE_BRANCH
- )
- }
+ this.pushToGithub(sessionData, shouldUpdateStagingLite)
return { sha: stagingCreateResult.value.newSha }
}
@@ -101,51 +115,43 @@ export default class GitFileCommitService {
const defaultBranch = STAGING_BRANCH
logger.info("Updating file in local Git file system")
const filePath = directoryName ? `${directoryName}/${fileName}` : fileName
- const updatePromises = [
- this.gitFileSystemService.update(
- sessionData.siteName,
- filePath,
- fileContent,
- sha,
- sessionData.isomerUserId,
- defaultBranch
- ),
- ]
+ const stagingUpdateResult = await this.gitFileSystemService.update(
+ sessionData.siteName,
+ filePath,
+ fileContent,
+ sha,
+ sessionData.isomerUserId,
+ defaultBranch
+ )
const shouldUpdateStagingLite =
- filePath &&
+ !!filePath &&
isReduceBuildTimesWhitelistedRepo(sessionData.growthbook) &&
!isFileAsset({ fileName, directoryName })
+ let stagingLiteUpdateResult
if (shouldUpdateStagingLite) {
- updatePromises.push(
- this.gitFileSystemService.update(
- sessionData.siteName,
- filePath,
- fileContent,
- sha,
- sessionData.isomerUserId,
- this.STAGING_LITE_BRANCH
- )
+ stagingLiteUpdateResult = await this.gitFileSystemService.update(
+ sessionData.siteName,
+ filePath,
+ fileContent,
+ sha,
+ sessionData.isomerUserId,
+ STAGING_LITE_BRANCH
)
}
- const results = await Promise.all(updatePromises)
- const [stagingUpdateResult, stagingLiteUpdateResult] = results
-
if (stagingUpdateResult.isErr()) {
throw stagingUpdateResult.error
- } else if (shouldUpdateStagingLite && stagingLiteUpdateResult.isErr()) {
+ } else if (
+ shouldUpdateStagingLite &&
+ stagingLiteUpdateResult &&
+ stagingLiteUpdateResult.isErr()
+ ) {
throw stagingLiteUpdateResult.error
}
- this.gitFileSystemService.push(sessionData.siteName, defaultBranch)
- if (shouldUpdateStagingLite) {
- this.gitFileSystemService.push(
- sessionData.siteName,
- this.STAGING_LITE_BRANCH
- )
- }
+ this.pushToGithub(sessionData, shouldUpdateStagingLite)
return { newSha: stagingUpdateResult.value }
}
@@ -161,50 +167,41 @@ export default class GitFileCommitService {
logger.info(
`Deleting directory in local Git file system for repo: ${sessionData.siteName}, directory name: ${directoryName}`
)
- const deletePromises = [
- this.gitFileSystemService.delete(
- sessionData.siteName,
- directoryName,
- "",
- sessionData.isomerUserId,
- true,
- STAGING_BRANCH
- ),
- ]
+ const stagingDeleteResult = await this.gitFileSystemService.delete(
+ sessionData.siteName,
+ directoryName,
+ "",
+ sessionData.isomerUserId,
+ true,
+ defaultBranch
+ )
const shouldUpdateStagingLite =
isReduceBuildTimesWhitelistedRepo(sessionData.growthbook) &&
!isFileAsset({ directoryName })
-
+ let stagingLiteDeleteResult
if (shouldUpdateStagingLite) {
- deletePromises.push(
- this.gitFileSystemService.delete(
- sessionData.siteName,
- directoryName,
- "",
- sessionData.isomerUserId,
- true,
- this.STAGING_LITE_BRANCH
- )
+ stagingLiteDeleteResult = await this.gitFileSystemService.delete(
+ sessionData.siteName,
+ directoryName,
+ "",
+ sessionData.isomerUserId,
+ true,
+ STAGING_LITE_BRANCH
)
}
- const results = await Promise.all(deletePromises)
- const [stagingDeleteResult, stagingLiteDeleteResult] = results
-
if (stagingDeleteResult.isErr()) {
throw stagingDeleteResult.error
- } else if (shouldUpdateStagingLite && stagingLiteDeleteResult.isErr()) {
+ } else if (
+ shouldUpdateStagingLite &&
+ stagingLiteDeleteResult &&
+ stagingLiteDeleteResult.isErr()
+ ) {
throw stagingLiteDeleteResult.error
}
- this.gitFileSystemService.push(sessionData.siteName, defaultBranch)
- if (shouldUpdateStagingLite) {
- this.gitFileSystemService.push(
- sessionData.siteName,
- this.STAGING_LITE_BRANCH
- )
- }
+ this.pushToGithub(sessionData, shouldUpdateStagingLite)
}
async delete(
@@ -222,55 +219,45 @@ export default class GitFileCommitService {
logger.info(
`Deleting file in local Git file system for repo: ${sessionData.siteName}, directory name: ${directoryName}, file name: ${fileName}`
)
- const defaultBranch = STAGING_BRANCH
const filePath = directoryName ? `${directoryName}/${fileName}` : fileName
- const deletePromises = [
- this.gitFileSystemService.delete(
- sessionData.siteName,
- filePath,
- sha,
- sessionData.isomerUserId,
- false,
- STAGING_BRANCH
- ),
- ]
+ const stagingDeleteResult = await this.gitFileSystemService.delete(
+ sessionData.siteName,
+ filePath,
+ sha,
+ sessionData.isomerUserId,
+ false,
+ STAGING_BRANCH
+ )
const shouldUpdateStagingLite =
isReduceBuildTimesWhitelistedRepo(sessionData.growthbook) &&
!isFileAsset({ directoryName })
+ let stagingLiteDeleteResult
if (shouldUpdateStagingLite) {
- deletePromises.push(
- this.gitFileSystemService.delete(
- sessionData.siteName,
- filePath,
- sha,
- sessionData.isomerUserId,
- false,
- this.STAGING_LITE_BRANCH
- )
+ stagingLiteDeleteResult = await this.gitFileSystemService.delete(
+ sessionData.siteName,
+ filePath,
+ sha,
+ sessionData.isomerUserId,
+ false,
+ STAGING_LITE_BRANCH
)
}
- const [stagingDeleteResult, stagingLiteDeleteResult] = await Promise.all(
- deletePromises
- )
-
if (stagingDeleteResult.isErr()) {
throw stagingDeleteResult.error
- } else if (shouldUpdateStagingLite && stagingLiteDeleteResult.isErr()) {
+ } else if (
+ shouldUpdateStagingLite &&
+ stagingLiteDeleteResult &&
+ stagingLiteDeleteResult.isErr()
+ ) {
throw stagingLiteDeleteResult.error
}
- this.gitFileSystemService.push(sessionData.siteName, defaultBranch)
- if (shouldUpdateStagingLite) {
- this.gitFileSystemService.push(
- sessionData.siteName,
- this.STAGING_LITE_BRANCH
- )
- }
+ this.pushToGithub(sessionData, shouldUpdateStagingLite)
}
async renameSinglePath(
@@ -283,50 +270,38 @@ export default class GitFileCommitService {
const defaultBranch = STAGING_BRANCH
logger.info("Renaming file/directory in local Git file system")
- const renamePromises = [
- this.gitFileSystemService.renameSinglePath(
- sessionData.siteName,
- oldPath,
- newPath,
- sessionData.isomerUserId,
- defaultBranch,
- message
- ),
- ]
-
- const shouldUpdateStagingLite =
- isReduceBuildTimesWhitelistedRepo(sessionData.growthbook) &&
- !isFileAsset({ directoryName: oldPath })
-
- if (shouldUpdateStagingLite) {
- renamePromises.push(
- this.gitFileSystemService.renameSinglePath(
- sessionData.siteName,
- oldPath,
- newPath,
- sessionData.isomerUserId,
- this.STAGING_LITE_BRANCH,
- message
- )
- )
- }
-
- const results = await Promise.all(renamePromises)
- const [stagingRenameResult, stagingLiteRenameResult] = results
+ const stagingRenameResult = await this.gitFileSystemService.renameSinglePath(
+ sessionData.siteName,
+ oldPath,
+ newPath,
+ sessionData.isomerUserId,
+ defaultBranch,
+ message
+ )
if (stagingRenameResult.isErr()) {
throw stagingRenameResult.error
- } else if (shouldUpdateStagingLite && stagingLiteRenameResult.isErr()) {
- throw stagingLiteRenameResult.error
}
- this.gitFileSystemService.push(sessionData.siteName, defaultBranch)
+ const shouldUpdateStagingLite =
+ isReduceBuildTimesWhitelistedRepo(sessionData.growthbook) &&
+ !isFileAsset({ directoryName: oldPath })
+
if (shouldUpdateStagingLite) {
- this.gitFileSystemService.push(
+ const stagingLiteRenameResult = await this.gitFileSystemService.renameSinglePath(
sessionData.siteName,
- this.STAGING_LITE_BRANCH
+ oldPath,
+ newPath,
+ sessionData.isomerUserId,
+ STAGING_LITE_BRANCH,
+ message
)
+ if (stagingLiteRenameResult.isErr()) {
+ throw stagingLiteRenameResult.error
+ }
}
+
+ this.pushToGithub(sessionData, shouldUpdateStagingLite)
return { newSha: stagingRenameResult.value }
}
@@ -340,51 +315,39 @@ export default class GitFileCommitService {
): Promise {
logger.info("Moving files in local Git file system")
const defaultBranch = STAGING_BRANCH
- const mvFilesResults = [
- this.gitFileSystemService.moveFiles(
+ const stagingMvFilesResult = await this.gitFileSystemService.moveFiles(
+ sessionData.siteName,
+ oldPath,
+ newPath,
+ sessionData.isomerUserId,
+ targetFiles,
+ defaultBranch,
+ message
+ )
+ if (stagingMvFilesResult.isErr()) {
+ throw stagingMvFilesResult.error
+ }
+
+ const shouldUpdateStagingLite =
+ isReduceBuildTimesWhitelistedRepo(sessionData.growthbook) &&
+ !isFileAsset({ directoryName: oldPath })
+
+ if (shouldUpdateStagingLite) {
+ const stagingLiteMvFilesResult = await this.gitFileSystemService.moveFiles(
sessionData.siteName,
oldPath,
newPath,
sessionData.isomerUserId,
targetFiles,
- defaultBranch,
+ STAGING_LITE_BRANCH,
message
- ),
- ]
- const shouldUpdateStagingLite =
- isReduceBuildTimesWhitelistedRepo(sessionData.growthbook) &&
- !isFileAsset({ directoryName: oldPath })
-
- if (shouldUpdateStagingLite) {
- mvFilesResults.push(
- this.gitFileSystemService.moveFiles(
- sessionData.siteName,
- oldPath,
- newPath,
- sessionData.isomerUserId,
- targetFiles,
- this.STAGING_LITE_BRANCH,
- message
- )
)
+ if (stagingLiteMvFilesResult.isErr()) {
+ throw stagingLiteMvFilesResult.error
+ }
}
- const results = await Promise.all(mvFilesResults)
- const [stagingMvFilesResult, stagingLiteMvFilesResult] = results
-
- if (stagingMvFilesResult.isErr()) {
- throw stagingMvFilesResult.error
- } else if (shouldUpdateStagingLite && stagingLiteMvFilesResult.isErr()) {
- throw stagingLiteMvFilesResult.error
- }
-
- this.gitFileSystemService.push(sessionData.siteName, defaultBranch)
- if (shouldUpdateStagingLite) {
- this.gitFileSystemService.push(
- sessionData.siteName,
- this.STAGING_LITE_BRANCH
- )
- }
+ this.pushToGithub(sessionData, shouldUpdateStagingLite)
return { newSha: stagingMvFilesResult.value }
}
}
diff --git a/src/services/db/GitFileSystemService.ts b/src/services/db/GitFileSystemService.ts
index 9c8b42a9b..76082506d 100644
--- a/src/services/db/GitFileSystemService.ts
+++ b/src/services/db/GitFileSystemService.ts
@@ -46,16 +46,20 @@ export default class GitFileSystemService {
this.git = git
}
- private getEfsVolPathFromBranch(branchName: string) {
+ private getEfsVolPathFromBranch(branchName: string): string {
return branchName === STAGING_LITE_BRANCH
? EFS_VOL_PATH_STAGING_LITE
: EFS_VOL_PATH_STAGING
}
- private getEfsVolPath(isStaging: boolean) {
+ private getEfsVolPath(isStaging: boolean): string {
return isStaging ? EFS_VOL_PATH_STAGING : EFS_VOL_PATH_STAGING_LITE
}
+ private isStagingFromBranchName(branchName: string): boolean {
+ return branchName !== STAGING_LITE_BRANCH
+ }
+
/**
* NOTE: We can do concurrent writes to the staging branch and the staging lite branch
* since they exist in different folders.
@@ -97,7 +101,7 @@ export default class GitFileSystemService {
isGitInitialized(
repoName: string,
- isStaging = true
+ isStaging: boolean
): ResultAsync {
const repoPath = isStaging
? `${EFS_VOL_PATH_STAGING}/${repoName}`
@@ -122,7 +126,7 @@ export default class GitFileSystemService {
isOriginRemoteCorrect(
repoName: string,
- isStaging = true
+ isStaging: boolean
): ResultAsync {
const originUrl = `git@github.com:${ISOMER_GITHUB_ORG_NAME}/${repoName}.git`
const repoPath = isStaging
@@ -149,11 +153,9 @@ export default class GitFileSystemService {
repoName: string,
branchName: string
): ResultAsync {
- return this.getFilePathStats(
- repoName,
- "",
- branchName !== STAGING_LITE_BRANCH
- )
+ const isStaging = this.isStagingFromBranchName(branchName)
+
+ return this.getFilePathStats(repoName, "", isStaging)
.andThen((stats) => {
if (!stats.isDirectory()) {
// Return as an error to prevent further processing
@@ -168,14 +170,14 @@ export default class GitFileSystemService {
}
return err(error)
})
- .andThen(() => this.isGitInitialized(repoName))
+ .andThen(() => this.isGitInitialized(repoName, isStaging))
.andThen((isGitInitialized) => {
if (!isGitInitialized) {
return err(false)
}
return ok(true)
})
- .andThen(() => this.isOriginRemoteCorrect(repoName))
+ .andThen(() => this.isOriginRemoteCorrect(repoName, isStaging))
.andThen((isOriginRemoteCorrect) => {
if (!isOriginRemoteCorrect) {
return err(false)
@@ -235,7 +237,7 @@ export default class GitFileSystemService {
getGitBlobHash(
repoName: string,
filePath: string,
- isStaging = true
+ isStaging: boolean
): ResultAsync {
const efsVolPath = isStaging
? EFS_VOL_PATH_STAGING
@@ -248,6 +250,7 @@ export default class GitFileSystemService {
logger.error(
`Error when getting Git blob hash: ${error} when trying to access ${efsVolPath}/${repoName}`
)
+ console.log(`revparse: HEAD:${filePath} for ${efsVolPath}/${repoName}`)
if (error instanceof GitError) {
return new GitFileSystemError("Unable to determine Git blob hash")
@@ -403,7 +406,7 @@ export default class GitFileSystemService {
}).map(() => `${efsVolPath}/${repoName}`)
}
- return this.isGitInitialized(repoName)
+ return this.isGitInitialized(repoName, isStaging)
.andThen((isGitInitialized) => {
if (!isGitInitialized) {
return errAsync(
@@ -416,7 +419,7 @@ export default class GitFileSystemService {
}
return okAsync(true)
})
- .andThen(() => this.isOriginRemoteCorrect(repoName))
+ .andThen(() => this.isOriginRemoteCorrect(repoName, isStaging))
.andThen((isOriginRemoteCorrect) => {
if (!isOriginRemoteCorrect) {
return errAsync(
@@ -791,7 +794,7 @@ export default class GitFileSystemService {
return new GitFileSystemError("An unknown error occurred")
}
),
- this.getGitBlobHash(repoName, filePath),
+ this.getGitBlobHash(repoName, filePath, true),
]).map((contentAndHash) => {
const [content, sha] = contentAndHash
const result: GitFile = {
@@ -858,7 +861,7 @@ export default class GitFileSystemService {
mediaUrl: `${dataUrlPrefix},${file.content}`,
mediaPath: `${directoryName}/${fileName}`,
type: fileType,
- addedTime: stats.ctimeMs,
+ addedTime: stats.birthtimeMs,
size: stats.size,
})
})
@@ -871,6 +874,7 @@ export default class GitFileSystemService {
branchName: string
): ResultAsync {
const efsVolPath = this.getEfsVolPathFromBranch(branchName)
+ const isStaging = this.isStagingFromBranchName(branchName)
return this.getFilePathStats(
repoName,
directoryPath,
@@ -909,7 +913,7 @@ export default class GitFileSystemService {
const path = directoryPath === "" ? name : `${directoryPath}/${name}`
const type = isDirectory ? "dir" : "file"
- return this.getGitBlobHash(repoName, path)
+ return this.getGitBlobHash(repoName, path, isStaging)
.orElse(() => okAsync(""))
.andThen((sha) =>
ResultAsync.combine([
@@ -929,7 +933,7 @@ export default class GitFileSystemService {
sha,
path,
size: type === "dir" ? 0 : stats.size,
- addedTime: stats.ctimeMs,
+ addedTime: stats.birthtimeMs,
}
return okAsync(result)
@@ -955,6 +959,7 @@ export default class GitFileSystemService {
): ResultAsync {
let oldStateSha = ""
const efsVolPath = this.getEfsVolPathFromBranch(branchName)
+ const isStaging = this.isStagingFromBranchName(branchName)
return this.getLatestCommitOfBranch(repoName, branchName)
.andThen((latestCommit) => {
// It is guaranteed that the latest commit contains the SHA hash
@@ -979,7 +984,7 @@ export default class GitFileSystemService {
return okAsync(true)
})
.andThen(() =>
- this.getGitBlobHash(repoName, filePath).andThen((sha) => {
+ this.getGitBlobHash(repoName, filePath, isStaging).andThen((sha) => {
if (sha !== oldSha) {
return errAsync(
new ConflictError(
@@ -1044,6 +1049,8 @@ export default class GitFileSystemService {
): ResultAsync {
let oldStateSha = ""
const efsVolPath = this.getEfsVolPathFromBranch(branchName)
+ const isStaging = this.isStagingFromBranchName(branchName)
+
return this.getLatestCommitOfBranch(repoName, branchName)
.andThen((latestCommit) => {
if (!latestCommit.sha) {
@@ -1084,7 +1091,7 @@ export default class GitFileSystemService {
if (isDir) {
return okAsync(true) // If it's a directory, skip the blob hash verification
}
- return this.getGitBlobHash(repoName, path).andThen((sha) => {
+ return this.getGitBlobHash(repoName, path, isStaging).andThen((sha) => {
if (sha !== oldSha) {
return errAsync(
new ConflictError(
From 844aac7997afad11303f5e586a66c9b6a07fa4f5 Mon Sep 17 00:00:00 2001
From: Kishore <42832651+kishore03109@users.noreply.github.com>
Date: Mon, 4 Dec 2023 06:21:52 +0800
Subject: [PATCH 2/5] Untitled commit
---
src/services/db/GitFileCommitService.ts | 2 --
1 file changed, 2 deletions(-)
diff --git a/src/services/db/GitFileCommitService.ts b/src/services/db/GitFileCommitService.ts
index e3710ec98..4930c3694 100644
--- a/src/services/db/GitFileCommitService.ts
+++ b/src/services/db/GitFileCommitService.ts
@@ -1,5 +1,3 @@
-import { okAsync } from "neverthrow"
-
import GithubSessionData from "@root/classes/GithubSessionData"
import UserWithSiteSessionData from "@root/classes/UserWithSiteSessionData"
import { STAGING_BRANCH, STAGING_LITE_BRANCH } from "@root/constants"
From f64528ea5ad0cbfa9a016ddfe963e796117bf9d9 Mon Sep 17 00:00:00 2001
From: Kishore <42832651+kishore03109@users.noreply.github.com>
Date: Mon, 4 Dec 2023 06:34:47 +0800
Subject: [PATCH 3/5] Untitled commit
---
.../db/__tests__/GitFileSystemService.spec.ts | 25 +++++++++++++------
1 file changed, 18 insertions(+), 7 deletions(-)
diff --git a/src/services/db/__tests__/GitFileSystemService.spec.ts b/src/services/db/__tests__/GitFileSystemService.spec.ts
index a6887c2c5..c38cbabe1 100644
--- a/src/services/db/__tests__/GitFileSystemService.spec.ts
+++ b/src/services/db/__tests__/GitFileSystemService.spec.ts
@@ -248,7 +248,10 @@ describe("GitFileSystemService", () => {
checkIsRepo: jest.fn().mockResolvedValueOnce(true),
})
- const result = await GitFileSystemService.isGitInitialized("fake-repo")
+ const result = await GitFileSystemService.isGitInitialized(
+ "fake-repo",
+ true
+ )
expect(result._unsafeUnwrap()).toBeTrue()
})
@@ -258,7 +261,10 @@ describe("GitFileSystemService", () => {
checkIsRepo: jest.fn().mockResolvedValueOnce(false),
})
- const result = await GitFileSystemService.isGitInitialized("fake-repo")
+ const result = await GitFileSystemService.isGitInitialized(
+ "fake-repo",
+ true
+ )
expect(result._unsafeUnwrap()).toBeFalse()
})
@@ -288,7 +294,8 @@ describe("GitFileSystemService", () => {
})
const result = await GitFileSystemService.isOriginRemoteCorrect(
- "fake-repo"
+ "fake-repo",
+ true
)
expect(result._unsafeUnwrap()).toBeTrue()
@@ -304,7 +311,8 @@ describe("GitFileSystemService", () => {
})
const result = await GitFileSystemService.isOriginRemoteCorrect(
- "fake-repo"
+ "fake-repo",
+ true
)
expect(result._unsafeUnwrap()).toBeFalse()
@@ -316,7 +324,8 @@ describe("GitFileSystemService", () => {
})
const result = await GitFileSystemService.isOriginRemoteCorrect(
- "fake-repo"
+ "fake-repo",
+ true
)
expect(result._unsafeUnwrapErr()).toBeInstanceOf(GitFileSystemError)
@@ -515,7 +524,8 @@ describe("GitFileSystemService", () => {
const result = await GitFileSystemService.getGitBlobHash(
"fake-repo",
- "fake-dir/fake-file"
+ "fake-dir/fake-file",
+ true
)
expect(result._unsafeUnwrap()).toBe("fake-hash")
@@ -528,7 +538,8 @@ describe("GitFileSystemService", () => {
const result = await GitFileSystemService.getGitBlobHash(
"fake-repo",
- "fake-dir/fake-file"
+ "fake-dir/fake-file",
+ true
)
expect(result._unsafeUnwrapErr()).toBeInstanceOf(GitFileSystemError)
From 9f8bca5f4ac8ee42a9a794dabce07a57aa8cc2cb Mon Sep 17 00:00:00 2001
From: Kishore <42832651+kishore03109@users.noreply.github.com>
Date: Wed, 6 Dec 2023 15:36:25 +0800
Subject: [PATCH 4/5] Untitled commit
---
src/services/db/GitFileCommitService.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/services/db/GitFileCommitService.ts b/src/services/db/GitFileCommitService.ts
index 4930c3694..4dc640dff 100644
--- a/src/services/db/GitFileCommitService.ts
+++ b/src/services/db/GitFileCommitService.ts
@@ -39,7 +39,7 @@ export default class GitFileCommitService {
)
)
}
- await res
+ return res
}
async create(
From 7d9bcedb6687f663f60a587082a50047b16dd088 Mon Sep 17 00:00:00 2001
From: Kishore <42832651+kishore03109@users.noreply.github.com>
Date: Wed, 6 Dec 2023 15:53:07 +0800
Subject: [PATCH 5/5] Untitled commit
---
src/services/db/GitFileSystemService.ts | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/services/db/GitFileSystemService.ts b/src/services/db/GitFileSystemService.ts
index 76082506d..5f4cbe402 100644
--- a/src/services/db/GitFileSystemService.ts
+++ b/src/services/db/GitFileSystemService.ts
@@ -250,7 +250,6 @@ export default class GitFileSystemService {
logger.error(
`Error when getting Git blob hash: ${error} when trying to access ${efsVolPath}/${repoName}`
)
- console.log(`revparse: HEAD:${filePath} for ${efsVolPath}/${repoName}`)
if (error instanceof GitError) {
return new GitFileSystemError("Unable to determine Git blob hash")