From a13786d6cc185822f5940582efde2349ef729145 Mon Sep 17 00:00:00 2001 From: HampusM Date: Thu, 24 Jun 2021 22:50:38 +0200 Subject: Refactored the backend yet again --- packages/server/src/api/util.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'packages/server/src/api/util.ts') diff --git a/packages/server/src/api/util.ts b/packages/server/src/api/util.ts index b05ebb7..e1eaa2c 100644 --- a/packages/server/src/api/util.ts +++ b/packages/server/src/api/util.ts @@ -1,5 +1,6 @@ -import { GitAPI } from "./git"; -import { RequestInfo } from "./git_types"; +import { Commit } from "../git/commit"; +import { Repository } from "../git/repository"; +import { RequestInfo } from "../git/http"; import { readdir } from "fs"; type VerificationResultType = "SUCCESS" | "NOT_FOUND" | "INVALID" | "ACCESS_DENIED"; @@ -51,12 +52,12 @@ export function verifyRepoName(base_dir: string, repo_name: string): Promise { +export async function verifySHA(repository: Repository, sha: string): Promise { if(!(/^[a-fA-F0-9]+$/u).test(sha)) { return new VerificationResult("INVALID", "sha"); } - const object_exists = await git.doesObjectExist(repo_name, sha); + const object_exists = await Commit.lookupExists(repository, sha); if(!object_exists) { return new VerificationResult("NOT_FOUND", "object"); -- cgit v1.2.3-18-g5258