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

chore: revert to copy instead of clone #1182

Merged
merged 1 commit into from
Mar 5, 2024
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
6 changes: 1 addition & 5 deletions src/routes/formsg/formsgGGsRepair.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ import { ResultAsync, errAsync, fromPromise, okAsync } from "neverthrow"

import { config } from "@config/config"

import {
EFS_VOL_PATH_STAGING,
EFS_VOL_PATH_STAGING_LITE,
} from "@root/constants"
import { EFS_VOL_PATH_STAGING_LITE } from "@root/constants"
import GitFileSystemError from "@root/errors/GitFileSystemError"
import InitializationError from "@root/errors/InitializationError"
import { consoleLogger } from "@root/logger/console.logger"
Expand Down Expand Up @@ -150,7 +147,6 @@ export class FormsgGGsRepairRouter {
.andThen(() =>
fromPromise(
this.reposService.setUpStagingLite(
path.join(EFS_VOL_PATH_STAGING, repoName),
path.join(EFS_VOL_PATH_STAGING_LITE, repoName),
repoUrl
),
Expand Down
13 changes: 10 additions & 3 deletions src/services/identity/ReposService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ export default class ReposService {
.checkout("staging") // reset local branch back to staging

// Make sure the local path is empty, just in case dir was used on a previous attempt.
await this.setUpStagingLite(stgDir, stgLiteDir, repoUrl)
await this.setUpStagingLite(stgLiteDir, repoUrl)
}

createDnsIndirectionFile = (
Expand Down Expand Up @@ -375,16 +375,23 @@ export const createRecords = (zoneId: string): Record[] => {
.map(() => undefined)
}

async setUpStagingLite(stgDir: string, stgLiteDir: string, repoUrl: string) {
async setUpStagingLite(stgLiteDir: string, repoUrl: string) {
fs.rmSync(`${stgLiteDir}`, { recursive: true, force: true })
// create a empty folder stgLiteDir
fs.mkdirSync(stgLiteDir)
fs.cpSync(stgDir, stgLiteDir, { recursive: true })

// note: for some reason, combining below commands led to race conditions
// so we have to do it separately
// Create staging lite branch in other repo path

await this.simpleGit
.cwd({ path: stgLiteDir, root: false })
.clone(repoUrl, stgLiteDir)
await this.simpleGit.cwd({ path: stgLiteDir, root: false }).pull() // some repos are large, clone takes time
await this.simpleGit
.cwd({ path: stgLiteDir, root: false })
.checkout("staging")

if (fs.existsSync(path.join(`${stgLiteDir}`, `images`))) {
await this.simpleGit
.cwd({ path: stgLiteDir, root: false })
Expand Down
Loading