chore(server): core IoC 4 - getStreamBranch(es)ByNameFactory
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { db } from '@/db/knex'
|
||||
import {
|
||||
addCommitDeletedActivity,
|
||||
addCommitMovedActivity
|
||||
@@ -15,7 +16,7 @@ import {
|
||||
import { Roles } from '@/modules/core/helpers/mainConstants'
|
||||
import {
|
||||
createBranch,
|
||||
getStreamBranchByName
|
||||
getStreamBranchByNameFactory
|
||||
} from '@/modules/core/repositories/branches'
|
||||
import {
|
||||
deleteCommits,
|
||||
@@ -104,7 +105,7 @@ async function validateCommitsMove(
|
||||
}
|
||||
|
||||
const stream = streams[0]
|
||||
const branch = await getStreamBranchByName(stream.id, targetBranch)
|
||||
const branch = await getStreamBranchByNameFactory({ db })(stream.id, targetBranch)
|
||||
|
||||
if (
|
||||
!branch &&
|
||||
|
||||
@@ -21,7 +21,7 @@ import {
|
||||
import { CommitRecord } from '@/modules/core/helpers/types'
|
||||
import {
|
||||
getBranchByIdFactory,
|
||||
getStreamBranchByName,
|
||||
getStreamBranchByNameFactory,
|
||||
markCommitBranchUpdated
|
||||
} from '@/modules/core/repositories/branches'
|
||||
import {
|
||||
@@ -188,7 +188,7 @@ export async function createCommitByBranchName(
|
||||
const { notify = true } = options || {}
|
||||
|
||||
const branchName = params.branchName.toLowerCase()
|
||||
let myBranch = await getStreamBranchByName(streamId, branchName)
|
||||
let myBranch = await getStreamBranchByNameFactory({ db })(streamId, branchName)
|
||||
if (!myBranch) {
|
||||
myBranch = (await getBranchByIdFactory({ db })(branchName)) || null
|
||||
}
|
||||
@@ -272,7 +272,7 @@ export async function updateCommitAndNotify(
|
||||
if (newBranchName) {
|
||||
try {
|
||||
const [newBranch, oldBranch] = await Promise.all([
|
||||
getStreamBranchByName(streamId, newBranchName),
|
||||
getStreamBranchByNameFactory({ db })(streamId, newBranchName),
|
||||
getCommitBranch(commitId)
|
||||
])
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
GetViewerResourcesForComments,
|
||||
GetViewerResourcesFromLegacyIdentifiers
|
||||
} from '@/modules/comments/domain/operations'
|
||||
import { GetStreamBranchesByName } from '@/modules/core/domain/branches/operations'
|
||||
import {
|
||||
ResourceIdentifier,
|
||||
ResourceIdentifierInput,
|
||||
@@ -15,10 +16,7 @@ import {
|
||||
ViewerUpdateTrackingTarget
|
||||
} from '@/modules/core/graph/generated/graphql'
|
||||
import { CommitRecord } from '@/modules/core/helpers/types'
|
||||
import {
|
||||
getBranchLatestCommits,
|
||||
getStreamBranchesByName
|
||||
} from '@/modules/core/repositories/branches'
|
||||
import { getBranchLatestCommits } from '@/modules/core/repositories/branches'
|
||||
import {
|
||||
getAllBranchCommits,
|
||||
getCommitsAndTheirBranchIds,
|
||||
@@ -76,7 +74,7 @@ const getObjectResourceGroupsFactory =
|
||||
}
|
||||
|
||||
type GetVersionResourceGroupsIncludingAllVersionsFactoryDeps = {
|
||||
getStreamBranchesByName: typeof getStreamBranchesByName
|
||||
getStreamBranchesByName: GetStreamBranchesByName
|
||||
getAllBranchCommits: typeof getAllBranchCommits
|
||||
}
|
||||
|
||||
@@ -158,7 +156,7 @@ const getVersionResourceGroupsIncludingAllVersionsFactory =
|
||||
}
|
||||
|
||||
type GetVersionResourceGroupsLoadedVersionsOnlyDeps = {
|
||||
getStreamBranchesByName: typeof getStreamBranchesByName
|
||||
getStreamBranchesByName: GetStreamBranchesByName
|
||||
getSpecificBranchCommits: typeof getSpecificBranchCommits
|
||||
getBranchLatestCommits: typeof getBranchLatestCommits
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user