Skip to content

Commit

Permalink
chore(quickie): delete quickie for gh
Browse files Browse the repository at this point in the history
  • Loading branch information
kishore03109 committed Dec 3, 2023
1 parent ce03cb0 commit 2f033d4
Show file tree
Hide file tree
Showing 9 changed files with 189 additions and 592 deletions.
3 changes: 0 additions & 3 deletions src/integration/Notifications.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import {
import { getAuthorizationMiddleware } from "@root/middleware"
import { NotificationsRouter as _NotificationsRouter } from "@root/routes/v2/authenticated/notifications"
import GitFileCommitService from "@root/services/db/GitFileCommitService"
import GitHubCommitService from "@root/services/db/GithubCommitService"
import { BaseDirectoryService } from "@root/services/directoryServices/BaseDirectoryService"
import { ResourceRoomDirectoryService } from "@root/services/directoryServices/ResourceRoomDirectoryService"
import { CollectionPageService } from "@root/services/fileServices/MdPageServices/CollectionPageService"
Expand Down Expand Up @@ -71,12 +70,10 @@ const MOCK_SITE_MEMBER_ID = "1"

const gitFileSystemService = new GitFileSystemService(simpleGit())
const gitFileCommitService = new GitFileCommitService(gitFileSystemService)
const gitHubCommitService = new GitHubCommitService(isomerRepoAxiosInstance)
const gitHubService = new RepoService({
isomerRepoAxiosInstance,
gitFileSystemService,
gitFileCommitService,
gitHubCommitService,
})
const identityAuthService = getIdentityAuthService(gitHubService)
const usersService = getUsersService(sequelize)
Expand Down
4 changes: 1 addition & 3 deletions src/integration/Privatisation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import { AuthorizationMiddleware } from "@root/middleware/authorization"
import { SettingsRouter as _SettingsRouter } from "@root/routes/v2/authenticatedSites/settings"
import { SettingsService } from "@root/services/configServices/SettingsService"
import GitFileCommitService from "@root/services/db/GitFileCommitService"
import GitHubCommitService from "@root/services/db/GithubCommitService"
import { BaseDirectoryService } from "@root/services/directoryServices/BaseDirectoryService"
import { ResourceRoomDirectoryService } from "@root/services/directoryServices/ResourceRoomDirectoryService"
import { CollectionPageService } from "@root/services/fileServices/MdPageServices/CollectionPageService"
Expand Down Expand Up @@ -100,12 +99,11 @@ jest.mock("../services/identity/DeploymentClient", () =>
)
const gitFileSystemService = new GitFileSystemService(simpleGit())
const gitFileCommitService = new GitFileCommitService(gitFileSystemService)
const gitHubCommitService = new GitHubCommitService(isomerRepoAxiosInstance)

const gitHubService = new RepoService({
isomerRepoAxiosInstance,
gitFileSystemService,
gitFileCommitService,
gitHubCommitService,
})
const configYmlService = new ConfigYmlService({ gitHubService })
const usersService = getUsersService(sequelize)
Expand Down
4 changes: 1 addition & 3 deletions src/integration/Reviews.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ import {
} from "@fixtures/users"
import { ReviewRequestStatus } from "@root/constants"
import GitFileCommitService from "@root/services/db/GitFileCommitService"
import GitHubCommitService from "@root/services/db/GithubCommitService"
import { BaseDirectoryService } from "@root/services/directoryServices/BaseDirectoryService"
import { ResourceRoomDirectoryService } from "@root/services/directoryServices/ResourceRoomDirectoryService"
import { CollectionPageService } from "@root/services/fileServices/MdPageServices/CollectionPageService"
Expand Down Expand Up @@ -105,12 +104,11 @@ import { sequelize } from "@tests/database"

const gitFileSystemService = new GitFileSystemService(simpleGit())
const gitFileCommitService = new GitFileCommitService(gitFileSystemService)
const gitHubCommitService = new GitHubCommitService(isomerRepoAxiosInstance)

const gitHubService = new RepoService({
isomerRepoAxiosInstance,
gitFileSystemService,
gitFileCommitService,
gitHubCommitService,
})
const configYmlService = new ConfigYmlService({ gitHubService })
const usersService = getUsersService(sequelize)
Expand Down
4 changes: 1 addition & 3 deletions src/integration/Sites.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import { statsMiddleware } from "@root/middleware/stats"
import { SitesRouter as _SitesRouter } from "@root/routes/v2/authenticated/sites"
import { isomerRepoAxiosInstance } from "@root/services/api/AxiosInstance"
import GitFileCommitService from "@root/services/db/GitFileCommitService"
import GitHubCommitService from "@root/services/db/GithubCommitService"
import { BaseDirectoryService } from "@root/services/directoryServices/BaseDirectoryService"
import { ResourceRoomDirectoryService } from "@root/services/directoryServices/ResourceRoomDirectoryService"
import { CollectionPageService } from "@root/services/fileServices/MdPageServices/CollectionPageService"
Expand Down Expand Up @@ -67,13 +66,12 @@ const mockPermissions = { push: true }
const mockPrivate = true

const gitFileSystemService = new GitFileSystemService(simpleGit())
const gitHubCommitService = new GitHubCommitService(isomerRepoAxiosInstance)

const gitFileCommitService = new GitFileCommitService(gitFileSystemService)
const gitHubService = new RepoService({
isomerRepoAxiosInstance,
gitFileSystemService,
gitFileCommitService,
gitHubCommitService,
})
const configYmlService = new ConfigYmlService({ gitHubService })
const usersService = getUsersService(sequelize)
Expand Down
3 changes: 0 additions & 3 deletions src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ import { SgidAuthRouter } from "./routes/v2/sgidAuth"
import RepoManagementService from "./services/admin/RepoManagementService"
import GitFileCommitService from "./services/db/GitFileCommitService"
import GitFileSystemService from "./services/db/GitFileSystemService"
import GitHubCommitService from "./services/db/GithubCommitService"
import RepoService from "./services/db/RepoService"
import { PageService } from "./services/fileServices/MdPageServices/PageService"
import { ConfigService } from "./services/fileServices/YmlFileServices/ConfigService"
Expand Down Expand Up @@ -170,14 +169,12 @@ const simpleGitInstance = new simpleGit({
})

const gitFileSystemService = new GitFileSystemService(simpleGitInstance)
const gitHubCommitService = new GitHubCommitService(isomerRepoAxiosInstance)
const gitFileCommitService = new GitFileCommitService(gitFileSystemService)

const gitHubService = new RepoService({
isomerRepoAxiosInstance,
gitFileSystemService,
gitFileCommitService,
gitHubCommitService,
})

const repoManagementService = new RepoManagementService({
Expand Down
26 changes: 7 additions & 19 deletions src/services/db/GitHubService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,11 @@ export default class GitHubService {
fileName,
directoryName,
isMedia = false,
branchName = STAGING_BRANCH,
}: {
content: string
fileName: string
directoryName: string
isMedia: boolean
branchName: string
}
) {
const { accessToken, siteName, isomerUserId: userId } = sessionData
Expand Down Expand Up @@ -185,7 +183,7 @@ export default class GitHubService {
const params = {
message,
content: encodedContent,
branch: branchName,
branch: STAGING_BRANCH,
}

const resp = await this.axiosInstance.put(endpoint, params, {
Expand All @@ -209,18 +207,14 @@ export default class GitHubService {

async read(
sessionData: UserWithSiteSessionData,
{
fileName,
directoryName,
branchName = STAGING_BRANCH,
}: { fileName: any; directoryName: any; branchName?: string }
{ fileName, directoryName }: { fileName: any; directoryName: any }
) {
const { accessToken } = sessionData
const { siteName } = sessionData
const endpoint = this.getFilePath({ siteName, fileName, directoryName })

const params = {
ref: branchName,
ref: STAGING_BRANCH,
}

const resp = await this.axiosInstance.get(endpoint, {
Expand All @@ -241,10 +235,7 @@ export default class GitHubService {

async readMedia(
sessionData: UserWithSiteSessionData,
{
fileSha,
branchName = STAGING_BRANCH,
}: { fileSha: any; branchName?: string }
{ fileSha }: { fileSha: any; branchName?: string }
) {
/**
* Files that are bigger than 1 MB needs to be retrieved
Expand All @@ -254,7 +245,7 @@ export default class GitHubService {
const { accessToken } = sessionData
const { siteName } = sessionData
const params = {
ref: branchName,
ref: STAGING_BRANCH,
}

const blobEndpoint = this.getBlobPath({ siteName, fileSha })
Expand Down Expand Up @@ -379,24 +370,21 @@ export default class GitHubService {
sha,
fileName,
directoryName,
branchName = STAGING_BRANCH,
}: {
sha: string
fileName: string
directoryName: string
branchName?: string
}
) {
const { accessToken, siteName, isomerUserId: userId } = sessionData
try {
const endpoint = this.getFilePath({ siteName, fileName, directoryName })

let fileSha = sha
if (!sha || branchName === STAGING_LITE_BRANCH) {
if (!sha) {
const { sha: retrievedSha } = await this.read(sessionData, {
fileName,
directoryName,
branchName,
})
fileSha = retrievedSha
}
Expand All @@ -408,7 +396,7 @@ export default class GitHubService {
})
const params = {
message,
branch: branchName,
branch: STAGING_BRANCH,
sha: fileSha,
}

Expand Down
Loading

0 comments on commit 2f033d4

Please sign in to comment.